Geo-Blocking

The Get-Blocking shortcode for WordPress can be used to block users from specific countries to access an individual web page or the entire website. You can display different restriction messages to visitors based on their location. For this shortcode to work, your website needs to be served through Cloudflare. Check below for example implementations and shortcode documentation:

Geo-Blocking Examples

We disabled the shortcode from working on this page so you can access its content & documentation. You may check the geo-blocking in action here – the page will automatically display a block message which is customizable.

Geo-Blocking Shortcodes

Shortcode
[x3m-geoblock country="US, FR" message="restricted"]
The shortcode can be used to block access to your content to visitors from one or multiple countries. Above examples targets users in the US and France, users which will receive the message from the “restricted.html” file. Users restricted will be received by the message displayed over a dark layover which blocks interaction with your website.

The restriction applies to the page/pages where the shortcode is implemented. If you want to make website-wide available, consider implementing the shortcode in a footer widget for example.

Geo-Blocking Documentation

First, the most important requirement for this shortcode to work is for your website to be served through Cloudflare (free plan works). Cloudflare offers a geo-location data which is used by our shortcode to display the appropriate content to specific countries. By default this service is activated in Cloudflare, but in case your website does not display the correct content to specific countries, check for the Cloudflare’s CF-IP Country header to be active (enable the “Add visitor location headers” Managed Transform in your Cloudflare dashboard).

Here are the shortcode option settings available for Geo-Blocking:

Shortcode Settings Details
country=”US” used to include the country to block access to your page or website. Multiple countries can be included in this list, listing them comma separated (ex: “US, JP, FR”).
The countries listed should use the 2 letter/alpha-2 notation
message=”restricted” used to set which message to be displayed to restricted users.

X3M Shortcodes plugin includes a templates/geo-block-messages/ folder where there are a default.html and a restricted.html file. In this folder you can create other basic html files with your own content to be displayed. Use the name of the file in the message=”” setting, without including .html