Local geolocation testing

Why override your IP locally

Logic Hop uses visitors' IP addresses in a variety of ways, and it can be important to test with a valid or specific IP address — especially when working with geolocation. During local development your IP usually resolves to your local computer, which makes geolocation conditions impossible to test realistically.

Override your IP address

To override the IP address Logic Hop uses, implement the logichop_get_client_ip filter. To set a specific address, return the IP you want from the filter — for example, a function hooked to logichop_get_client_ip that returns '72.85.30.42'. Swap in any valid IP of your choice. Note that the filter only accepts valid IP addresses.

  • Set a specific IP: return a fixed address such as 72.85.30.42 from the filter
  • Use the forwarded IP: read HTTP_X_FORWARDED_FOR from $_SERVER and return the first value when present

Questions this page should answer

Which filter overrides the Logic Hop client IP?

Use the logichop_get_client_ip filter. Return a valid IP address from your hooked function to override the address Logic Hop uses for geolocation.