ip-location-block-record-logs

May 11, 2021
Darko G.

Specify the condition of recording logs.

Description

The filter hook “ip-location-block-record-logs” can change the condition of recording logs depending on the situation.

Parameters

  • $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.

Use case

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-location-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-location-block-record-logs', 'my_record_logs', 10, 3 );
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

0.2.1.1

Leave a Reply

Your email address will not be published.

© 2022 - IP Location Block by IDEOLOGIX Media