3

Is it possible to restrict access to a page based on a visitor's country?

For instance, only users in the US can view the FAQ page?

Thanks!

Brad Bell
  • 67,440
  • 6
  • 73
  • 143
Jeremy P
  • 51
  • 3

2 Answers2

4

Luke Holder has created a plugin that would help you in this situation.

Geo Plugin for Craft CMS

John Moylan
  • 458
  • 2
  • 7
1

I realise this is an old post, but it's something we've tackled recently and wanted to put out our solution.

If you're using CloudFlare you could use our Country Detect plugin, otherwise as John Moylan mentioned Luke Holder's Geo Plugin can achieve the same thing. The only advantage of our plugin is that it saves a bit of processing if you're already using CloudFlare.

You could then conditionally show content to US folks only at by something like this...

{% if craft.countryDetect.country == "US" %}
    {# Put your FAQs for USA here #}
{% elseif %}
    {# Content or redirect() goes here #}
{% endif %}
Mutual
  • 442
  • 2
  • 11