WP-CLI, Hooks & PHP API
Automate Geo-Blocker Pro from the command line or extend it with code.
WP-CLI commands
wp ygb status # version, license, database, rules, events today
wp ygb lookup 95.24.0.1 --url=/shop/ # location + full decision trace
wp ygb sync # download / update MaxMind City + ASN
wp ygb settings list # all settings as JSON
wp ygb settings get countries
wp ygb settings set is_enabled 1
wp ygb settings set countries '["RU","CN","GROUP:SANCTIONED"]'
wp ygb export --file=geo.json # settings + rules (no secret keys)
wp ygb import geo.json
wp ygb unban 203.0.113.7 # remove rate-limit ban + login lockout
wp ygb clear_logs
wp ygb report # send the weekly email nowSettings changed with set or import are validated exactly like in the admin, and page caches are purged.
PHP helpers
if ( function_exists( 'ygb_get_visitor_country' ) ) {
$country = ygb_get_visitor_country(); // 'US', 'BD', 'UNKNOWN' or 'LOCAL'
$location = ygb_get_visitor_location(); // country, continent, state_code, state_name, city, asn, asn_org
}Filters
Filter | Use |
|---|---|
| Override the detected visitor IP. |
| Return an array to short-circuit the location lookup (e.g. your own GeoIP service). |
| Modify the location array after lookup. |
| Add your own country groups (shown in every picker as GROUP:KEY). |
| Add crawlers and their reverse-DNS domains. |
| Final say on bot verification. |
| Network names treated as VPN/datacenter. |
| Cloudflare IP ranges used for safe header trust. |
| Custom location for the MaxMind files. |
| Maximum rows kept in the log table (default 100,000). |
Actions
ygb_purge_cache– fired when settings change; clear your own caches here.
REST API
The admin uses /wp-json/ygb/v1/* (requires manage_options). Public endpoints: GET /ygb/v1/check (cache-safe mode decision) and POST /ygb/v1/challenge.
Example: add a custom group
add_filter( 'ygb_country_groups', function ( $groups ) {
$groups['NORDIC'] = array( 'label' => 'Nordic countries', 'countries' => array( 'DK', 'FI', 'IS', 'NO', 'SE' ) );
return $groups;
} );
Was this guide helpful?