It’s very common for developers to work locally when developing WordPress projects. It’s also common that when testing local projects your IP address reflects that of your local computer.

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.

Override Your IP Address

To override the IP address Logic Hop uses you’ll need to implement the logichop_get_client_ip filter as such:

Set a Specific IP Address

function my_override_ip ( $client_IP ) {

  return '72.85.30.42';
}
add_filter( 'logichop_get_client_ip', 'my_override_ip' );

Just swap out 72.85.30.42 with the valid IP address of your choice.

Note: The logichop_get_client_ip filter only accepts valid IP addresses.

Set to the HTTP_X_FORWARDED_FOR IP Address

function my_override_ip ( $client_IP ) {

  if ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $_SERVER ) ) {
    $ip = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
    $client_IP = $ip[0];
  }

  return $client_IP;
}
add_filter( 'logichop_get_client_ip', 'my_override_ip' );

Using the HTTP_X_FORWARDED_FOR method will allow you to use a browser extension to specify a specific IP address before visiting your local development environment.

Note: Logic Hop only sets your IP address when starting a new session, such as visiting your site in a new incognito window.

Reference

Today Only! Save 10% on One of 2021's Top 10 WordPress Plugins With Code TOP10
Yo ! Thanks for checking out Logic Hop!