Support » Developing with WordPress » Lookup country for existing IP

  • I have wpforms free, I get the IP address, but dont have the country. How can I lookup the country for existing IP? Currently I store into the db wpforms and ideally the lookup solution is also stored on the db, so that I can establish easily the link between IP and country.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You could import a lookup table into your DB, then develop bespoke code to do the lookup and include the country name in any output where it’d be useful information. Such a table would be very large if it were at all comprehensive. You’d need to carefully choose the source of the data to have any hope of it being reasonably accurate.

    Be aware that IP geolocation is not terribly reliable even with the very best data sources. Getting the country correct is somewhat reliable, but don’t expect accuracy better than that. For example, my current IP geolocates hundreds of kms away from my actual location. But it is in the right country.

    Instead of importing a huge dataset that would eventually become out of date, I recommend utilizing a geolocation API service. In general you should get more accurate results than by relying on imported data.

    Thread Starter kirilb

    (@kirilb)

    ok thanks. And what geolocation API service could you recommend?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.