The IP address of the server for the current requester.
Description
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.
Parameters
- $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 '98.139.183.24'; // yahoo.com
else
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. Since
1.2.0