Specify the condition of recording logs.
The filter hook “ip-geo-block-record-logs” can change the condition of recording logs depending on the situation.
$record
(int) Type of recording (0:none 1:blocked 2:passed 3:unauth 4:auth 5:all).
$hook
(string) 'comment'
, 'xmlrpc'
, 'login'
, 'admin'
or 'public'
.
$validate
(array) An associative array for validation result.
The following code snippet in your theme’s functions.php
can bypass WP-ZEP
validation against the direct request to
/wp-content/plugins/my-plugin/…/*.php
.
/**
* Example : Usage of 'ip-geo-block-record-logs'
* Use case: Prevent recording logs when it requested from own country
*
* @param int $record 0:none 1:blocked 2:passed 3:unauth 4:auth 5:all
* @param string $hook 'comment', 'xmlrpc', 'login', 'admin' or 'public'
* @param array $validate the result of validation which contains:
* 'ip' => string ip address
* 'auth' => int authenticated (>= 1) or not (0)
* 'code' => string country code
* 'time' => unsinged processing time for examining the country code
* 'provider' => string IP geolocation service provider
* 'result' => string 'passed' or the reason of blocking
* @return int $record modified condition
*/
function my_record_logs( $record, $hook, $validate ) {
/* if request is from my country and passed, then no record */
if ( 'JP' === $validate['code'] && 'passed' === $validate['result'] )
$record = 0;
return $record;
}
add_filter( 'ip-geo-block-record-logs', 'my_record_logs', 10, 3 );
"mu-plugins" (ip-geo-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.
2.1.1