Add Country Specific Address State Code to Gravity Forms Address Fields for Non U.S Types

Gravity forms Country FieldsGravity forms is the most popular premium forms plugin for WordPress and one of the best plugins all round. If you’re a non U.S developer, you may need to customize the address fields to display states, provinces or regions for a specific country.

Gravity forms, out of the box, only displays United states & Canadian states with a default International field.

In this tutorial i’ll show you how to add  country filters to create non U.S address types for Australian state’s, U.K states and Brazilian states for custom address fields.

There’s already an International address type included but it doesn’t display specific countries or non U.S states.

Add this code to your theme’s functions.php file (A child theme or custom functions.php file is suggested otherwise your custom code will be lost when you update your theme).

Requirements

If you don’t already own a Gravity forms license, you’ll need to purchase Gravity forms license.

United Kingdom Address Type Code

If you’re not from any of these countries you could easily edit the above code for your own country and create address form fields using the excellent form plugin, Gravity forms.

Australian Address Type Code

I’ve already written several other posts on how to customize gravity forms and i’ll be writing more in the future as its such a hugely popular plugin.

Here’s another address type for Brazil:

Brazilian Address Type Code

If you have any other country code address types you have used already, you are welcome to send them to me which will help other Developers using the contact form.


Comments

3 responses to “Add Country Specific Address State Code to Gravity Forms Address Fields for Non U.S Types”

  1. […] Add Country Specific Address State Code to Gravity Forms Address Fields for Non U.S Types […]

  2. Please how can I add Kenya Address Type Code. normally use P.O. Box

    Thanks in advance.

  3. […] Finally, I wanted to share some code for you Gravity Form lovers out there. I do realise that this isn’t to do with decluttering, but it is a way to to improve WordPress. Gravity Forms is (in my opinion) the best forms plugin out there. It’s very powerful and I use it on all our clients’ websites. Unfortunately, Gravity Forms seems to be fairly US-centric and only caters for US addresses in their forms. You can select “international” but that isn’t very flexible. The following code snippets allow you to add support for UK, Australian and Brazilian addresses. With a bit of messing around you would be able to modify them for other countries too. Let me know what you think! They all come from this wonderful article on WPSites. […]

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.