Skip to content

Instantly share code, notes, and snippets.

@thewebprincess
Forked from GaryJones/gravity-au.php
Created January 4, 2014 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thewebprincess/8250139 to your computer and use it in GitHub Desktop.
Save thewebprincess/8250139 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'gform_address_types', 'your_plugin_slug_australian_address' );
/**
* Set Gravity Forms custom addresses for Australia.
*
* @since 1.0.0
*
* @param array $address_types Existing address formats.
* @param int $form_id Form ID.
*
* @return array Amended address formats.
*/
function your_plugin_slug_australian_address( array $address_types ) {
$address_types['australia'] = array(
'label' => __( 'Australia', 'your-plugin-slug' ), //labels the dropdown
'country' => __( 'Australia', 'your-plugin-slug' ), //sets Australia as default country
'zip_label' => __( 'Post Code', 'your-plugin-slug' ),
'state_label' => __( 'State', 'your-plugin-slug' ),
'states' => array(
'',
__( 'Australian Capital Territory', 'your-plugin-slug' ),
__( 'New South Wales', 'your-plugin-slug' ),
__( 'Northern Territory', 'your-plugin-slug' ),
__( 'Queensland', 'your-plugin-slug' ),
__( 'South Australia', 'your-plugin-slug' ),
__( 'Tasmania', 'your-plugin-slug' ),
__( 'Victoria', 'your-plugin-slug' ),
__( 'Western Australia', 'your-plugin-slug' ),
),
);
return $address_types;
}
@thewebprincess
Copy link
Author

The slicker, tidier version of my older code with significant input from Gary Jones (kudos).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment