Skip to content

Instantly share code, notes, and snippets.

@webaware
Forked from thewebprincess/gravity-au.php
Last active January 4, 2016 05:47
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 webaware/f445808d0475ea0e02f2 to your computer and use it in GitHub Desktop.
Save webaware/f445808d0475ea0e02f2 to your computer and use it in GitHub Desktop.
Australian address fields in Gravity Forms
<?php
/*
Plugin Name: Gravity Forms Aussie Addresses
Plugin URI: https://gist.github.com/webaware/f445808d0475ea0e02f2
Description: Australian address fields in Gravity Forms
Author: thewebprincess
Author URI: https://thewebprincess.com/
Version: 0.0.1
@link https://gist.github.com/thewebprincess/7855509
*/
if (!defined('ABSPATH')) {
exit;
}
/**
* add Australia as an address type to Address fields
* @param array $address_types
* @param int $form_id
* @return array
*/
add_filter('gform_address_types', function($address_types, $form_id) {
$address_types['australia'] = array(
'label' => 'Australia',
'country' => 'Australia',
'zip_label' => 'Post Code',
'state_label' => 'State',
'states' => array (
'',
'Australian Capital Territory',
'New South Wales',
'Northern Territory',
'Queensland',
'South Australia',
'Tasmania', 'Victoria',
'Western Australia'
),
);
return $address_types;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment