beee4life / acf-city-selector Goto Github PK
View Code? Open in Web Editor NEWAn ACF extension to create a new field type, where you can select a city based on country and provence/state.
An ACF extension to create a new field type, where you can select a city based on country and provence/state.
I have a similar issue to #15.
When I attach a city_selector field to a user, it appears to be working properly as follows:
Unfortunately the State and City fields are no longer rendered on the user profile screen. These fields are empty despite the fact that the selections are correctly stored in the usermeta table. If anything else is changed in the user profile, it is necessary to re-enter these fields in order to save the changes. This requires first selecting another country, state, city, then re-entering the original country, state and city.
I have no idea how to fix this. I tried adding the code shown in issue #15 to my functions.php but it made no difference.
Thanks in advance for any advice/assistance with this issue.
Impact
The plugin adds a database table named {$wpdb->prefix}cities upon plugin activation and imports cities from 3 different countries.
CREATE TABLE <?php echo wp_cities ( id int(6) unsigned NOT NULL auto_increment, city_name varchar(50) NULL, state_code varchar(3) NULL, state_name varchar(50) NULL, country_code varchar(2) NULL, country varchar(50) NULL, PRIMARY KEY (id) ) COLLATE utf8mb4_unicode_ci;
The option of importing cities from the existing 3 countries is in plugin's "Settings" page.
Currently in "Fields to use", there're following 4 options
Can you also add the option "State/province + City", for the case to use only 1 country?
Thanks a lot for the awesome plugin, regards!
Thanks for creating this, there’s surprising not a lot out there.
When you say works “on taxonomy terms” I’m not clear how to implement this and make a connection with my custom taxonomy?
As far as I can see I can only select one Field Type - either City Selector or Taxonomy and I can’t see a filter to connect taxonomy terms.
Ideally I would like to store as hierarchical taxonomy country>state>city in order to simplify use in other functions like 3rd part search plugins.
Any suggestions would be appreciated.
If you select just a country and state or just a country, nothing returns on the front end without a city selected. Would be great if, when I only have the country selected, the country will come through when getting the field.
Thanks!!
Hi @Beee4life
I create Armenia country import csv https://gist.github.com/airarm/11ed9183a501ea6a011b9c180999b65a
You can add Armenia country to your supported countries list
Thank you for great plugin!
Thanks for the great plugin.
I have a question and probably will be handy too in the future for others. Are we able to use meta query when we search/filter using wp_query? I was thinking it'd be similar like ACF group_field, but it's not working for me, maybe you can point out the right direction.
'meta_query' => array(
array(
'key' => 'field_name_countryCode',
'compare' => '=',
'value' => 'AU',
)
)
Hi there, I love your plugin, but was curious if you're looking into expanding the country set. The countries you support are great, but obviously missing a ton.
Also, would you consider offering a multi-pack that contains all the cities for a savings instead of purchasing all separately? Or even a subscription where you pay and get all future updates?
That would be a great alternative and I saw many users asking how to do it in the forums, and your plugin can do it, usto changing the values I believe?
Hello, first of all very good work!
My query is how to store country / state / city fields as metadata to be able to filter later?
I am using Search & Filter, and it does not detect the waterfall fields.
https://www.bobz.co/dynamically-populate-select-fields-choice-in-advanced-custom-fields
I'm following this thread to be able to auto-fill cascading fields, but I'm done with your plugin, which is fantastic.
Might you help me? or tell me how to do the exposed turorial?
Thanks!
FYI your PayPal link to purchase countries is coming up with error “We're sorry, things don't appear to be working right now. Please try again later.” So you can’t purchase country packages.
using this page https://acf-city-selector.com/get-countries/
I have a custom post type called 'Venues'.
I created an ACF Field Group for this custom post type, and 'acf-city-selector' is one of the fields in this group.
It works beautifully on:
But now I want to use it in a filter so site users can filter the posts to their own location. I have it working in Search and Filter Pro BUT it doesn't provide the 3 droptdowns for Country, State and City but rolls them all into a single dropdown showing codes but not names. This is not useable.
So I'd appreciate some advice on a search plugin that will work with City-Selector or some PHP code that will enable it to display properly in my filter.
Thanks
Hello Dear,
I'm using this in a Repeater, and it made changes to all fields while I change only 1 country field ....
Dear Beee4life,
I am trying to import cities for Lebanon.
Everything worked fine and all the cities, districts and country were imported succeffuly.
But nothing is showing in the ACF field.
The CSV file example is: Aadouiye;Akkar;Akkar;LB;Lebanon.
I tried your first suggestion to delete the transients (mentioned in a previous issue closed for no reply) but it didn't work.
Nothing is showing. Any idea to how I can fix this?
Thank you.
Hi,
I've been trying to import raw text pasted using "Import CSV data (from clipboard)" and when trying to import it drops me an error with the strpos function on line 607 in file /inc/acf-functions.php. I changed that line and now it works:
// Removed line as it receives array instead of file, we check if its array to import raw
//if ( strpos( $file_name, '.csv', -4 ) !== false ) {
if( !is_array($file_name) ){
Also, the cities for the countries Aruba, Curaçao, Grenada, Haiti are not available.
Regards.
It's not showing the correct saved data, just blank
modifique el archivo ACF_City_Selector.php linea 132
state_code varchar(5) NULL,
para que funcione para Perú
Hi @Beee4life ,
I have managed to install the plugin and imported the cities of Portugal in the database, added a custom field for my JetEngine custom post type, everything worked smoothly except the minor issues I reported in #62 .
However, I am not able to find a way to use JetEngine Dynamic Fields to get the values of city/state/country, and can't use JetSmartFilters to filter my listings with the different cities.
Is it in your radar to make such enhancement in future, or is it too much to ask?
In my option, these are very useful features which can benefit a lot of users.
Looking forward to your feedback, regards!
Hey,
I've added a few cities.
When I set the field and select "All fields [default]" under "Fields to use", I see the Country > Region > City perfectly.
When I select "Country + City" I can select country, but the cities list is empty.
See this short video with screen capture for more details:
https://sharing.clickup.com/clip/p/t1866731/c9951cd2-4013-47e7-968d-104e255c9f41/screen-recording-2022-08-13-10%3A11.webm
What am I doing wrong?
Thanks
Hi, I'm from Indonesia. I use your plugin and I'm very satisfied.
But, I found some (maybe) problems about your plugin. I will explain my problem..
I added an ACF City Selector to the field using the City Selector type (listed in the Options section). Then I added some states and cities to my database. And it works like a screenshot below.
This post ID = 4015
Then I click the Update button to update my post. That works, because ACF City Selector post meta has been saved in the database, like the screenshot below.
But when I edit my post again, ACF City Selector does not show selected country, states and cities like the following screenshot.
Please help me how to fix this problem. thanks.
Hi,
This looks very promising for a non-developer like myself. Any chance you'd add the ability to choose a custom -hierarchical- taxonomy as a source for the selector? The applications would be limitless. Country/State, Make/Model, Product Category/Subcategory.
The us.csv file has the errors 'There are too few columns on all lines. Since your file is not accurate anymore, the file is deleted.
Regards,
Hello! Thanks for great plugin. I checked your demo version here http://acfcs.berryplasman.com/see-it-in-action/ and it looks really good. Could you help me, please? I need the cities and states for US, but i can't find a great csv file with all data. I noticed in demo, that you have the US states/cities. Could you send me the csv file, please?
Also could you explain how to show this 3 fields on the front-end as on your demo? I'd be really greatful for your reply! Thanks.
@Beee4life I found an issue on your lastest 1.3.1 version of plugin.
If the City name contain apex (or apostrophe), it won't "saved" properly.
For example:
"City name" is saved properly.
"City's name" won't saved.
Debugging a bit: in database the value of City appear stored as serialized array without any escape char before the apex.
I opened the "acfcs-functions.php" and edit the lines 536, 543 and 550 with:
$selected_value = esc_attr($stored_value);
Now the City with apex will appear properly as selected on the dropdown.
That's strange, before appling the above code, by echoing $key and $selected_value, they appears as equal strings, but at line 572 the ternary condition doesn't work as expected.
I'm no pretty sure about this method could be the best, maybe you need to check or escape the chars before store values.
I have not much time to investigate better, but take a look and check yourself.
I was hoping the users would be able to type in a country and it would show up in the search results, but it isn't. I am also using ACF better search. Or am I missing something?
Hello,
Since a few days, my new cities aren't displaying into the select list when I'm editing/creating a new custom post type event, which is using the city selector. My new cities are correctly added into the database (I've checked by the search tab into the City Selector plugin and into the database of the website). But, when I'm editing an event, I don't have the new added cities displaying into the select list.
I've tried deleting transients, deleting cache, etc. I've ACF and City Selector up to date.
Do you have any idea what is going wrong?
It was working fine a few days ago but now, it's not and I can't find why...
Thanks a lot for your feedback.
Best regards,
Anaïs
I am sending you a file with the Greek cities and regions. If you want to include it in the default installation of your plugin.
Find the file here: https://gist.github.com/assoscoupa/9e94f8f88b8990dbfbffec6d92ba0c12
I'm trying to import city, state & country data and I get the following error. I am importing global data, and Australia use a 3 digit state abbreviation. How can I fix this?
Hello there,
It would be awesome , not only using CSV for uploading countries, but with Custom Post Types and Taxonomies maybe?
Where your CPT can be a country etc. or something else.. this plugin can be used in many sittuations, one nice one is something like a simple booking by city and cpt.
We encountered a very long waiting time, after selecting a country the interface freezes.
It looks that it makes second request for load all cities and in cases like India it is about 2.7s.
Is there are reason to pre load all cities right after load states?
Also is there are way to optimize server time? Currently execution of get_states_call time is about 450-600ms, so for users is start to be not good experience.
Thank you for support
Hey,
Great plugin, just what I needed! Got a suggestion though:
It would be nice to be able to set a default country so you only need to set the state/province and city.
Verder goed bezig! ;-)
Hello guys,
a long time ago we did a huge import of cities (like 100 entries or so) in a project and is working normally. Now the unhappy part is when we try to import a new city and all the process is ok but unfortunately it is not showing in ACF selectors in our post as others cities/countries do.
The new city is showing in acf-city-selector dashboard and it is correctly added to DB (sounds obvious) but we dont know why is not showing in the selectors. Not sure if it is an ACF or ACF-City-Selector issue.
Any clue on how to fix this?
When I try to add new data through pasting from clipboard or typing
the data will get validated. However, when I try to click import csv data, I get this error.
However, using a .csv
file is alright. No errors.
( ! ) Warning: strpos() expects parameter 1 to be string, array given in public/wp-content/plugins/acf-city-selector/inc/acfcs-functions.php on line 622
Currently Zeeland and and Gelderland are defined as ZL and GL, but should be ZE and GE.
See https://en.wikipedia.org/wiki/ISO_3166-2:NL#Current_codes
Hello and thanks for this plugin.
I've installed it and it works on backoffice very well.
However I would like to display it on front page in a search form.
I've seen that you make it here : http://acfcs.berryplasman.com/see-it-in-action/
Can you help me how to do this ?
Thanks in advance.
Regards,
Kévin
We have cases on the project where user needs just select a country.
Currently if select a country, do not select a city and then click save, country is not saving.
Also in case if just to show country field only and save it is not saving results.
WordPress 5.4.2
ACF PRO 5.8.9
Thank you for the AMAZING work on the plugin!
When I add the city selector with those settings.
Then go to: [sitename]wp-login.php?action=register
And try to select a city, I get the following error in the dev tools console:
Uncaught ReferenceError: ajaxurl is not defined
I found that the ajax url is added only on the wp_head
hook.
The hook called for the registration page is called login_head
.
By adding
add_action( 'login_head', 'city_selector_ajaxurl' );
Right below line 13, triggers the login_head, and ads to ajax and fixes the problem.
Did you want me to PR?
Let me know
Hi! Could you add fields in admin panel for select necessary countries list or wp filter in populate_country_select and other? This will be enough to support localization via wpml for example.
Hello, thanks for the interesting plugin.
How can I use city selector field in elementor or jet engine form ?
Hi
I have purchased the GB csv and imported it. Unfortunately it is full of errors, including missing counties, incorrect counties, counties that no longer exist, and many of the towns/cities are actually small villages or hamlets and so are likely to be of little use.
Also this should be called UK (United Kingdom) as it contains data from Northern Ireland which is not in Great Britain.
Thanks
Hello, thanks for the interesting plugin. We are moving a site from Drupal to WordPress and were searching for the plugin functionality - being able to select country > region > city.
We have a directory of clubs (a custom post type). The URL structure is:
website.com/clubs/post
We'd also like visitors to be able to find clubs based on country / region / city, with archive pages like this:
website.com/clubs/germany
website.com/clubs/germany/brandenburg
website.com/clubs/germany/brandenburg/potsdam
If a visitor clicks on the first link, they'll see all clubs in Germany; if they click on the second, they'll see all clubs in Brandenburg and so on.
Looking at the documentation I didn't find anything about this, but based on issues #100 and #85, it sounds like this is not possible with the plugin?
I have been reading about how to create custom permalinks containing custom fields, but haven't found anything about how to create archive pages based on custom fields. Perhaps it's not possible. The plugin is great and UI very easy to use, but it sounds like we will have to use native WordPress hierarchical taxonomies instead.
Hello, I'm using this plugin more than half year, and it working good. But after last update I got fatal error. I used this function acfcs_get_country_name() in my functions.php. Could you help me with this?
Hello, Congratulations for the plugin you did.
I am trying to use get_field_object () to get all the
States and cities, to create a filter in the frontend, could you help me?
Here is an example of how I'm trying to do it.
Thank you
$field_key = "field_5b4df093b4581";
$field = get_field_object($field_key);
if( $field )
{
echo '';
foreach( $field['choices'] as $k => $v )
{
echo '' . $v . '';
}
echo '';
}
Hello,
When someone selects Country, State and City, after the update, the value of the city does not remain in the form. The mentioned price simply does not appear in the form and in addition to this, there is no city to choose from.
If he chooses another state then he sees the corresponding cities. After that if someone selects the previous state then the cities of the first state return available for selection.
watch this video below:
https://www.youtube.com/watch?v=yDT_p0GtDK8
Just bought the Canada file
Download
Imported
"There are too many columns on line 162. Since your file is not accurate anymore, the file is deleted.
There are too many columns on line 2658. Since your file is not accurate anymore, the file is deleted."
Why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.