Gravity Forms – How to set default address type

By default WordPress has three address type formats

  • International
  • United States
  • Canadian

International is the default address type and provides the most flexibility for the various address formats used worldwide.

The gform_default_address_type filter can be used to specify a default address type. The code below shows how you can use change the default address type – this way each time you add a new address field you won’t need to select the address type.

To use, simply copy in your theme’s functions php file, directly below the opening <?php line

In this example we’re setting ‘United States’ as the default address type

add_filter( 'gform_default_address_type', 'itsg_set_default_country',  10, 2 );
function itsg_set_default_country( $default_address_type, $form_id ) {
    return 'us';
}

In this example we’re setting ‘Canadian’ as the default address type

add_filter( 'gform_default_address_type', 'itsg_set_default_country',  10, 2 );
function itsg_set_default_country( $default_address_type, $form_id ) {
    return 'canadian';
}

If you want to create your own address format, for example an Australian format see how to add Australian address type format.

Note: the gform_default_address_type was introduced in Gravity Forms version 2.0.3.3 – if you have a lower version installed you will need to update.

Was this article helpful?

Related Articles