Snippet to make Gravity Forms Address Entry more British

Gravity Forms is fantastic tool for collecting names, email address and postal addresses. However, GravityForms is a US plugin, so the default form labels are all US or Canada-centric. Here’s a simple tweak that you can add to functions.php to make your custom address form show UK-labels for addresses.

By default, Gravity Forms will show:

  • State / Province / Region
  • Zip / Postal Code

Which is fine, but for UK-only websites, we’d like to be a little more British. So if you copy the following snippet of code into your template functions.php, you’ll end up with much more UK-centric labels for your address entry on your Gravity Forms.

/**
* Function to make the address fields GravityForms more British.
*/
function customiseFormLabels($addressTypes, $formID)
{
$addressTypes['international']['zip_label'] = 'Post Code';
$addressTypes['international']['state_label'] = 'County';

return $addressTypes;
}

// Use this one to change all gravity address forms to be more British
add_filter('gform_address_types', 'customiseFormLabels', 10, 2);

// To only change the labels for Form ID = 2, use the following instead.
// Note that the form ID goes after gform_address_types as gform_address_types_ID
//add_filter('gform_address_types_2', 'customiseFormLabels', 10, 2);

Instead, you’ll get the following:

  • County
  • Post Code

Much more British. You may now sing the National Anthem. :)

Subscribe to our mailing list

* indicates required Email Address * First Name * What tips do you want to receive? WordPress Tips Business & Marketing Tips

Written by Dan Harrison

Dan Harrison is the lead developer and director of WP Doctors Ltd, a web development agency specialising in writing bespoke tools for WordPress-based websites that save time, hassle and money. You can follow Dan on Twitter here: @DanJHarrison and WP Doctors here: @wpdoctors.

7 Comments

Leave a comment
  1. David Lockie January 16, 2012 at 12:56 pm #

    Nice tip Dan :) Thanks for sharing.

    • Dan Harrison January 16, 2012 at 1:18 pm #

      Thanks David. A client asked me to sort it out recently, and I thought others would like to know too. :)

      Dan

  2. mark oliver hawkins May 21, 2012 at 7:58 am #

    Hi Dan

    Just found this tip, very good timing as I have just bought GF for a Northampton client of mine.

    Great site BTW, thank you for your great tips, hae just started a new WordPress user group here in Milton Keynes and would like to share these if its OK with you guys?

    Cheers for now.

    • Dan Harrison May 21, 2012 at 10:24 am #

      @Mark

      Glad you find it useful. No probs to share these tips with your group, but please do share the blog URLs, rather than just copying the tips. Thanks!

      Dan

  3. Jon September 28, 2012 at 6:27 pm #

    Hi Dan,

    The main issue I’m having is validating the postcode field. Do you know whether this is possible?

  4. Andy January 18, 2013 at 12:57 am #

    Lifesaver, just what I needed, thanks.

Leave a Reply