Forminator Pro – How to get Country Name or City Name in WordPress Form?

People Have been looking for getting Country and/or City name using IP in WPMU Forminator Pro Form. Kindly follow these steps to get IP based Country and/or City on WordPress Form using Forminator PRO. I created a simple Workaround but I believe it can help you.
By 6 months ago

People Have been looking for getting Country and/or City name using IP in WPMU Forminator Pro Form.

Kindly follow these steps to get IP based Country and/or City on WordPress Form using Forminator PRO.

I created a simple Workaround but I believe it can help you.

Download this code:
https://gist.github.com/patrickfreitasdev/3e19d9693ab03ba577dea99955dd5573

Add it as a mu-plugin:
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

Update the line 13 using your custom form ID:

if(id === 1645){

And enable this form to load from Ajax

Create two hidden fields, in the first one select user IP

Second one custom value, you can leave that empty:

You will be able to use the {hidden-2} in your email template which will render the country:

Let me explain the code.

It selects both hidden fields dynamically based on your form ID, line 15 & 16.

In line 20 it creates the URL to get the data based on IP from this service https://www.iplocate.io/api/lookup/8.8.8.8

After the data returned to the JavaScript, it updates the hidden-2 adding the country name, line 27.

Let us know if this worked for you.

Share
asktechnicians

Recent Posts