The associative array for validation.
Description
The filter hook “ip-location-block-xxxxx” where xxxxx
is one of comment
, xmlrpc
, login
, admin
and public
can affect the validation of this plugin.
Parameters
- $validate
(array) An associative array for validation result.
Here are the keys and values in this associative array.
Key | Value |
---|---|
ip | IP address |
auth | authenticated or not |
code | country code |
time | processing time |
provider | geolocation API |
result | validation result |
Use case
function my_whitelist( $validate ) {
$whitelist = array(
'JP', // should be upper case
);
$validate['result'] = 'blocked';
if ( in_array( $validate['code'], $whitelist ) ) {
$validate['result'] = 'passed';
}
return $validate;
}
add_filter( 'ip-location-block-login', 'my_whitelist' );
add_filter( 'ip-location-block-admin', 'my_whitelist' );
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