Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Australian address format for Gravity Forms.
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment