Integrate for Autocomplete Gravity Forms Address Field is an address lookup service that allows you to autocomplete addresses based on part of the address or a postcode.

In this tutorial, I’ll show you how to apply it to the standard address field in Gravity Forms.

First things first, you’ll need to sign up for an account with and get an API key which we’ll use in the code below.

Then on your form, add an address field and in the Appearance options add the class getaddress-address-field to the “Custom CSS Class” field. This will allow us to target just this field in the code.

The code that you need to add to your WordPress theme’s functions.php is as follows:

add_filter('gform_field_content', 'add_getaddress_to_address_field', 10, 5);
function add_getaddress_to_address_field($content, $field, $value, $lead_id, $form_id) {
	if($field->cssClass == 'getaddress-address-field' && RG_CURRENT_VIEW != 'entry') {

		$getaddress_lookup_code = '
		<script src=""></script>
					county: "#input_'.$form_id.'_'.$field->id.'_4",
					town_or_city: "#input_'.$form_id.'_'.$field->id.'_3",
					postcode: "#input_'.$form_id.'_'.$field->id.'_5"
		document.addEventListener("getaddress-autocomplete-address-selected", function(e) {
			var country_field =, - 1)+"6";
			jQuery("#"+country_field).each(function() {
				if(jQuery(this).attr("value") == {
				} else if( == "England" || == "Wales" || == "Scotland" || == "Northern Ireland") {
					jQuery("#"+country_field).val("United Kingdom");

		$content = $content.$getaddress_lookup_code;

	return $content;

The functionality comes from some JavaScript code that they provide. So we’ll just add this to the field by hooking into the Gravity Forms filter gform_field_content and creating our own function add_getaddress_to_address_field.

We then add an if statement to check that the CSS class is getaddress-address-field and the current view isn’t the entry view.

The JS script is included and we add some JS code to marry up the various fields on the form.

You’ll need to ensure that you add your API key where it has XXXYYYZZZ otherwise the code won’t work.

Because the returns the country as Wales, Scotland, England and Northern Ireland instead of just United Kingdom, this would cause an issue if we just married up the country output with the Country field. So for that we add an additional bit of JS code that checks the country value and if it matches one of the home nations then it will update the country as United Kingdom instead.

We then add the JS into the $content variable which is what gets returned from the function.