Gravity Forms Australian States Dropdown List

Out of the box, Gravity Forms doesn’t include Australian states as a drop down list.

But luckily, Gravity Forms provides a hook that we can easily add in Australian States as a predefined list.  The list eliminates user free typing spelling errors and keeps everything consistent.

Add the following code to your functions.php file.  Save

Now go back and EDIT your gravity form.  Click on the address block which reveals options.  Select Australia as the address type.  Save.

Preview your form and you will now see the “State” field transformed to a drop down list.

Gravity forms Australian States

Always use a child theme.

Pro Tip: This can be modified to suit any country, simply by swapping out the country name and the list of states.

Enjoy!


function australian_address( $address_types, $form_id ) {
	$address_types['australia'] = array(
	'label'       =>   'Australia', //labels the dropdown
	'country'     =>   'Australia', //sets Australia as default country
	'zip_label'   =>   'Post Code', //what it says
	'state_label' =>   'State', //as above
	'states' => array( 
		'', 
		'Australian Capital Territory',
		'New South Wales',
		'Northern Territory',
		'Queensland',
		'South Australia',
		'Tasmania', 'Victoria',
		'Western Australia'
		)
	);
	return $address_types;
}
add_filter( 'gform_address_types', 'australian_address', 10, 2 );

Damon
Damon

Damon is the Principal Full Stack Developer at WPFix and freelance consultant. If you need help implementing anything wordpress related, please reach out to make an appointment.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

  • Setup a Wordpress Child Theme slider
  • Wordpress Better SEO GTMerix and Ligthouse Scores slider
  • Wordpress Instant Search Bar slider
  • woocommerce disable rich text editing for shop managers slider
  • Woocommerce admin multi SKU search slider