Documentation

Introduction

This plugin extends the functionality of ACF. Just install it and discover a new field choice. See it in action here.

Installation

  • Download the plugin here.
  • Upload it through FTP to wp-content/plugins or use the upload function and upload the downloaded zip file.
  • Activate the plugin through the plugins page.

Configuration

  • Open or create an ACF field group.
  • Click 'Add Field'.
  • Choose any name you want.
  • Choose any key you want.
  • Add the 'City Selector' field option (see example below).
  • Select whether to show labels above the input fields (default = yes).
  • Select whether to use a default country (default = false).
  • Save/publish the Field Group.

A new field option

Usage

To retrieve a stored value use the following code:

  1. $city_selector = get_field('field_name');

The variable $city_selector returns 5 values in an array:

  1. array(5) {
  2.   ["countryCode"]=>
  3.   string(2) "NL"
  4.   ["stateCode"]=>
  5.   string(5) "NH"
  6.   ["cityName"]=>
  7.   string(9) "Amsterdam"
  8.   ["stateName"]=>
  9.   string(13) "Noord-Holland"
  10.   ["countryName"]=>
  11.   string(11) "Netherlands"
  12. }

Output it as follows:

  1. $city_selector = get_field('field_name');
  2. echo 'I live in ' . $city_selector['cityName'];
  3. echo 'which is in ' . city_selector['stateName'] . ' (' . city_selector['stateCode'] . ')'; 
  4. echo ' which lies in the country ' . $city_selector['country'] . ' (' . $city_selector['countryCode'] . ')';

This outputs:

"I live in Amsterdam which is in Noord-Holland (NH) which lies in the country Netherlands (NL)"

Actions

There are a few hooks available to add your own custom actions.

Find them here.

Filters

There are a few filters available to override values.

Find them here.

Functions

There are a few functions available as well, for an easy retrieval of data.

Find detailed info here.

Countries

If you install the plugin you get 3 countries included;

  • Belgium
  • Luxembourg
  • Netherlands

You can delete them from the settings page (if you want). And re-import them separately (if you would only need 1 or 2).

Get more countries

If you would like to get more countries for your form, you can create a CSV formatted file/data set and import them manually. Please find more info about this in the contextual help menus.

We also have some 'pre-made country packages', which are ready to be imported. Click here to see which countries are available.

Contributors

Berry Plasman (Plugin author)
Jarah de Jong (Javascript)
John McDonald (German translations)

Support

If you need support, please turn to GitHub (for now).