Skip to main content

AddressZen Ninja Forms Integration

Add Address Lookup to your Ninja Forms pages.

Demo

Activate Address Lookup on your address collection forms-screenshot

info

If you need support, you can either reach out to us on our support page.

Installation

This integration works by adding our Address Validation tools using WordPress' form editor. Below are the instructions to add Address Lookup.

Enable Dev Mode

On your WordPress dashboard, click on the 'Ninja Forms' tab, followed by 'Settings'. Here, scroll down to 'Advanced Settings' and check the box for 'Form Builder "Dev Mode"'. This will be required when using the name attribute for your input fields.

Enable Dev Mode-screenshot

Create Address Inputs

Add address input fields to your form. To do so, select the 'Single Line Text' field and drag it into the form. Once clicked, you can update the label text.

A basic address form to capture a correct UK address should have the following fields:

  • Address line one
  • Address line two
  • City
  • State
  • ZIP Code

Create address fields-screenshot

You can optionally include additional fields.

Add Custom Name Attributes

For Address Lookup to identify the output fields, add name attributes to your address fields. To do so, click on the address field, and then the 'Advanced' dropdown. Here, you will find the CUSTOM NAME ATTRIBUTE field, which you can update. Remember to click on 'DONE' when complete.

Add a custom name attribute-screenshot

Add Address Lookup

Install and Initialise Plugin

On the WordPress admin dashboard, click on the 'Pages' tab, followed by 'Add New'. Now, click on the 'Add block' icon and look for the 'Custom HTML' option.

Custom HTML block-screenshot

Subsequently, add the following two script tags within the HTML block to load the plugin and then to initialise it.

Lastly, click on ‘Append a Ninja Form’ dropdown which is on the ‘Page’ tab and select your Ninja Form.

<script src="https://cdn.jsdelivr.net/npm/@addresszen/address-lookup"></script>

<script>
document.addEventListener("DOMContentLoaded", function(event) {
jQuery(document).on('nfFormReady', function() {
AddressZen.AddressLookup.setup({
apiKey: "YOUR_API_KEY",
outputFields: {
line_1: 'input[name="street_line_1"]',
line_2: 'input[name="street_line_2"]',
city: 'input[name="city"]',
state: 'input[name="state"]',
zip_plus_4_code: 'input[name="zipcode"]'
}
});
});
});
</script>
caution

Take special care to:

  1. Insert your API Key in the apiKey field
  2. Match the names of your address fields. If your Address Line One has the shortcode [text* line_1], ensure that line_1 reads 'input[name="line_1"]'
  3. Ensure inputField points to the same field as line_1 to have the Address Lookup appear there

Configuration

See our Address Lookup Plugin Documentation if you wish to customise Address Lookup.