Gravity Forms

Geo Controller provides built-in integration with Gravity Forms, allowing you to add geographic fields, automatically detect visitor information, and collect structured location data through WordPress forms.

The integration introduces dedicated Gravity Forms fields for country selection, country-region-city selection, and IP address detection. It also integrates with Gravity Forms’ existing country and IP handling mechanisms.

This functionality is especially useful for international contact forms, customer registration, regional inquiries, geographic lead collection, and websites that need location information without requiring visitors to enter every detail manually.

How the Integration Works

Geo Controller extends Gravity Forms through its native field registration system and WordPress hooks.

When the integration is active, a dedicated Geo Controller Fields group becomes available in the Gravity Forms editor.

The group contains three custom fields:

  • Select Country — displays a country dropdown with geographic preselection support.
  • Country, Region and City — provides connected dropdowns for selecting geographic locations.
  • IP Address — displays the visitor’s detected IP address in a read-only text field.

These fields integrate with Gravity Forms entries and can be included in form notifications using Gravity Forms’ standard merge-tag functionality.

Requirements

Before configuring the integration, make sure:

  • WordPress is installed and running.
  • Gravity Forms is installed and activated.
  • Geo Controller is installed and activated.
  • Geo Controller can retrieve the geographic information required by your form.
  • The Gravity Forms integration is enabled where your Geo Controller version provides an integration setting.

Once the integration is loaded, Geo Controller registers its custom field types with Gravity Forms.

Adding Geographic Fields to Gravity Forms

  1. Open the WordPress administration dashboard.
  2. Navigate to Forms and create a new form or edit an existing one.
  3. Open the available field groups in the Gravity Forms editor.
  4. Locate Geo Controller Fields.
  5. Select the geographic field you want to add.
  6. Configure its label and other supported field settings.
  7. Save the form and preview it before publishing.

Geo Controller fields support standard configuration options available for their respective field types, including labels, descriptions, required settings, and selected display options.

Select Country Field

The Select Country field displays a dropdown containing available countries.

Geo Controller retrieves the country list from its geographic library and supports automatic selection based on the visitor’s detected country.

For example, a visitor detected in the United States may see United States selected when the form loads.

Unlike a hidden geographic field, this dropdown allows the visitor to review and change the selected country.

How to Add the Country Field

  1. Open your form in the Gravity Forms editor.
  2. Expand Geo Controller Fields.
  3. Add Select Country to the form.
  4. Set the field label, such as Country.
  5. Enable the required option if visitors must select a country.
  6. Save and preview the form.

This field can be useful for international contact forms, registration processes, and regional customer inquiries.

Country, Region and City Field

The Country, Region and City field provides three connected location selectors in a single Gravity Forms field.

It allows visitors to select a country, followed by a region and city associated with the chosen country.

Geo Controller can initialize the field using detected geographic information, depending on the data available for the visitor.

How Dynamic Location Selection Works

When a visitor changes the selected country, Geo Controller sends an AJAX request to retrieve the available regions and cities for that country.

The region and city dropdowns are then updated without requiring a full page reload.

The integration uses Geo Controller’s geographic library to retrieve these location lists.

For example, when a visitor selects United States, the region selector can display available states, while the city selector can provide cities associated with the selected country.

Important: The implementation reloads region and city lists when the country changes. It does not independently guarantee that changing a region will filter the city list to that specific region.

How to Add the Location Field

  1. Open your form in the Gravity Forms editor.
  2. Locate the Geo Controller Fields group.
  3. Add the Country, Region and City field.
  4. Configure the field label and supported settings.
  5. Save the form.
  6. Preview the form and test the country selector.
  7. Verify that the region and city dropdowns update when a different country is selected.

The location field is useful for collecting structured geographic information while allowing visitors to correct or change automatically suggested values.

IP Address Field

The IP Address field retrieves the visitor’s detected IP address through Geo Controller.

Unlike the location dropdowns, the IP Address field is rendered as a read-only text input.

For example, a visitor may see an IPv4 or IPv6 address detected for the current request.

How to Add the IP Address Field

  1. Open the Gravity Forms editor.
  2. Expand Geo Controller Fields.
  3. Add the IP Address field.
  4. Configure the field label and supported options.
  5. Save and preview the form.

Geo Controller also integrates with Gravity Forms’ gform_ip_address filter, allowing its IP detection mechanism to supply the IP address used by Gravity Forms.

Security notice: A read-only HTML input is not a security boundary. Client-side values can be modified, and submitted values should not be treated as independently verified information.

Using Geographic Fields in Form Entries and Notifications

Geo Controller custom fields integrate with Gravity Forms’ entry handling.

After a form is submitted, the collected geographic values can be reviewed in the corresponding Gravity Forms entry.

The custom fields also include formatting logic for displaying saved information in entry details and entry lists.

Email Notifications

Gravity Forms supports merge tags that insert submitted field values into notification emails.

To include geographic information:

  1. Open your form settings.
  2. Navigate to Notifications.
  3. Edit an existing notification or create a new one.
  4. Use the Gravity Forms merge-tag selector to insert the relevant Geo Controller field values.
  5. Save the notification and submit a test entry.

For example, you can organize the notification body as follows:

New Contact Form Submission

Name: {Name:1}
Email: {Email:2}

Geographic Information:
{all_fields}

The field IDs in this example are illustrative and depend on your form configuration. The {all_fields} merge tag is a convenient way to include submitted fields without manually referencing individual field IDs.

Using Geographic Information for Conditional Logic

Geo Controller’s custom Gravity Forms fields declare support for conditional logic.

This can help you build location-dependent form experiences using the conditions supported by Gravity Forms and the selected field.

For example, you may configure a form to show additional questions when a visitor selects a particular country.

Conditional logic should be tested with the actual field values and configuration used in your form.

Note: Geographic preselection is a convenience feature. It does not guarantee that a visitor is physically located in the detected country.

Automatic Country Detection

Geo Controller uses IP-based geolocation data to determine a visitor’s likely geographic location.

When the country field is displayed, the plugin can use the detected country code as its initial selection.

The country, region and city field can also use available geographic information to initialize its location selectors.

Visitors can modify these values where the fields permit selection.

IP geolocation is approximate and may be affected by VPN services, proxies, mobile networks, corporate gateways, and inaccurate geographic databases.

Do not treat automatically selected location values as verified residential or billing addresses.

Gravity Forms Country List Integration

In addition to its custom geographic fields, Geo Controller integrates with the Gravity Forms gform_countries filter.

When Geo Controller’s country library returns a country list, the integration can provide that list to Gravity Forms.

This helps maintain consistency between country information supplied by Geo Controller and the country options used by Gravity Forms.

If Geo Controller does not return an available country list, the integration retains the country list supplied by Gravity Forms.

Page Caching and Geolocation

Geographic form preselection depends on information available when the form is rendered.

If a caching plugin, reverse proxy, or CDN serves previously generated HTML to another visitor, the initial geographic values may not match the current visitor’s location.

For example, a country dropdown previously rendered with United States selected could appear with the same selection for a visitor from the United Kingdom.

To avoid incorrect geographic defaults:

  • Review full-page caching for pages containing location-aware forms.
  • Test forms using different geographic locations.
  • Verify that the initial field values are appropriate for the current request.
  • Allow visitors to correct preselected location information.

The integration does not independently guarantee that full-page caches vary by visitor location.

Privacy and Data Protection

Geo Controller can add geographic information to form submissions, including IP addresses and selected location details.

Depending on the information collected and applicable law, this data may qualify as personal information.

Before collecting geographic data:

  • Determine which location fields are necessary for your intended purpose.
  • Explain relevant data collection in your privacy notice.
  • Apply an appropriate lawful basis where required.
  • Avoid collecting IP addresses when they are not needed.
  • Review who can access stored Gravity Forms entries.
  • Apply appropriate retention and deletion policies.

Geographic fields should not be used as a substitute for explicit confirmation of a visitor’s actual address or identity.

Troubleshooting

Geo Controller Fields Are Missing

If the Geo Controller Fields group does not appear in Gravity Forms:

  • Confirm that Gravity Forms and Geo Controller are active.
  • Verify that the Gravity Forms integration is enabled, where applicable.
  • Reload the form editor.
  • Check for PHP errors or plugin compatibility issues.
  • Ensure that Geo Controller’s integration files are installed correctly.

Country, Region or City Is Incorrect

Geographic preselection depends on IP geolocation accuracy and the availability of location records.

Visitors should be able to correct location information using the available dropdown fields.

If incorrect defaults appear consistently, test the form with full-page caching disabled.

Regions or Cities Do Not Update

The connected location field uses JavaScript and WordPress AJAX requests to retrieve geographic options.

If changing the country does not update the other selectors:

  • Check your browser developer console for JavaScript errors.
  • Verify that WordPress AJAX requests are functioning.
  • Check whether a caching or optimization plugin interferes with the integration script.
  • Make sure the selected country has available region or city data.
  • Confirm that the AJAX request is not blocked by a security plugin or server configuration.

IP Address Is Missing or Incorrect

Verify that Geo Controller detects the correct visitor IP address.

Websites operating behind reverse proxies, CDN services, or load balancers may require appropriate network and proxy configuration.

Do not assume that every incoming forwarding header represents a trusted client IP address.

For Developers

The Gravity Forms integration is implemented through the CFGP__Plugin__gravityforms class.

It registers three custom field types:

  • cfgp_gf_country — country selection.
  • cfgp_gf_country_region_city — combined country, region and city selection.
  • cfgp_gf_ip — detected IP address.

The integration also uses several Gravity Forms and WordPress hooks:

  • gform_field_groups_form_editor — adds the Geo Controller field group to the form editor.
  • gform_ip_address — supplies the detected visitor IP address.
  • gform_countries — integrates the Geo Controller country list.
  • gform_enqueue_scripts — registers integration JavaScript and CSS.
  • gform_register_init_scripts — enqueues the integration assets.

Dynamic country selection uses the WordPress AJAX action:

cfgp_gfield_autocomplete_location

The request includes a country code and a WordPress nonce. The server returns available region and city data using Geo Controller’s geographic library.

The AJAX endpoint supports both authenticated and unauthenticated visitors, allowing public-facing Gravity Forms to retrieve location options.

Developers should perform appropriate server-side validation before using submitted geographic values for security-sensitive or financially significant operations.

Important: Geo Controller’s Gravity Forms integration provides convenient geographic form fields and visitor location preselection. IP-based location information is approximate, and user-submitted values must not be treated as independently verified. Always test geographic fields, caching behavior, notifications, and data handling before deploying forms to production.

Was this page helpful?