AA Block country with redirect

Description

We know many times , people have to redirect their visitor to their respective pages according to their country. In this plugin we keep this option. So that you can easily redirect your visitor to their respective country.

Features

  1. IP Detection: Retrieves the visitor’s IP address using multiple server variables for reliability.
  2. Country Lookup via API: Optionally uses `ip-api.com` to detect the visitor’s country based on IP.
  3. Per-Post/Page Country Blocking: Enable or disable country blocking on individual posts, pages, or custom post types.
  4. Custom Blocked Countries: Set blocked countries using comma-separated ISO country codes (e.g., `US, IN, FR`).
  5. Global Country Blocking: Define global blocking rules that apply across the entire site.
  6. Redirect Blocked Users: Automatically redirect blocked visitors to a custom URL defined in plugin settings.
  7. Fallback Country Option: Specify a fallback country code in case API lookup fails.
  8. Meta Box UI: Adds a meta box to all public post types for easy control of country blocking.
  9. Secure Meta Handling: Uses WordPress nonces and capability checks to securely save meta data.
  10. Lightweight Integration: Executes only on the front-end using the `template_redirect` hook, keeping the admin side fast.

How to use it

  1. Configure Global Settings: Go to the plugin settings page and enable global country blocking. Set the list of blocked country codes and the redirect URL.
  2. Choose IP Lookup Method: Enable or disable IP lookup via `ip-api.com` based on your preference.
  3. Block Countries Globally: Visitors from blocked countries will be automatically redirected site-wide.
  4. Set Per-Post Blocking: Edit any post, page, or custom post type, and in the “AA Country Block Options” meta box, enable blocking and specify country codes to block for that content only.
  5. Save Changes: Update or publish your post/page to apply per-post blocking rules.
  6. Test Blocking: Use a VPN or proxy from a blocked country to verify the redirect works as expected.

Installation

  1. Download the plugin ZIP file from the source.
  2. Log in to your WordPress admin dashboard.
  3. Navigate to Plugins > Add New.
  4. Click Upload Plugin and select the downloaded ZIP file.
  5. Click Install Now and then Activate the plugin.
  6. Go to the plugin settings page to configure country blocking options.

Screenshots

Coming Soon ..

Changelog

  1. Version 1.0.1 (2025-06-02)
    1. Fixed IP detection logic to better handle proxy headers.
    2. Improved country code sanitization for per-post blocking.
    3. Added nonce verification to meta box save function for enhanced security.
    4. Optimized API request to `ip-api.com` with error handling improvements.
    5. Updated admin meta box UI for better usability.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“AA Block country with redirect” is open source software. The following people have contributed to this plugin.

Contributors