May 11, 2021
Darko G.

The IP address of the server for the current requester.


The filter hook “ip-location-block-ip-addr” assigns the IP address from which the current request comes. This plugin validate it by means of the country code and black / white list of extra IPs.


  • $ip
    (string) $_SERVER['REMOTE_ADDR']

Use case

The following code snippet in your theme’s functions.php can replace the IP address according to your browser’s user agent string. It’s useful to test this plugin’s functionality using browser’s addon which can be change the user agent string.

function my_replace_ip( $ip ) {
    if ( FALSE !== stripos( $_SERVER['HTTP_USER_AGENT'], 'your unique string' ) )
        return ''; // yahoo.com
        return $ip;
add_filter( 'ip-location-block-ip-addr', 'my_replace_ip' );
NOTE: It's also useful using VPN switcher addon to fake your IP address.
NOTE: When you select "mu-plugins" (ip-location-block-mu.php) as Validation timing , you should put your code snippet into drop-in.php in Geolocation API folder instead of functions.php. See My custom functions in “functions.php” doesn’t work. in FAQ for detail.



Leave a Reply

Your email address will not be published. Required fields are marked *

© 2023 - IP Location Block by IDEOLOGIX Media