Block certain countries from Contact Form 7?


Our brand has the same name as a company in Asia, and we get lots of messages relating to this via Contact Form 7 which messes up our marketing analytics. About 75% of mail is from these customers so I’d love to find a way to prevent this.

We only service the UK, so I’m wondering if there is a way to modify CF7 to block certain countries from using the form? Or if there is a better way of doing it?

[Reddit] Potential ways to limit unwanted CF7 mail caused by brand name confusion?

Our answer

Yes there is, using the free IP2Location Redirection plugin, which allows you to perform selective redirection based on visitor country(ies) and visited page(s).

So for visitors in your blacklisted country you can simply redirect your contact form page to your home page, and they’ll never get the opportunity to complete it.

Alternatively, you could redirect them to a dedicated explanation page.

This is what the relevant configuration page looks like:

IMPORTANT TO NOTE: the plugin says it won’t work behind a page cache. So, if you’re using a caching plugin (or Cloudflare or other CDN) make sure to add your contact page to the cache exclusion list for this to work.