WordPress Age Gate Verification for Canadian

For websites selling age-restricted products, such as alcohol, cannabis, or smoking-related products, age verification is required for visitors before entering the website. A process is called Age Gate.

In WordPress, it could be achieved easily by implementing an Age Gate plugin and there are tons of them available, mostly free of charge. Some may be better than other but functionality-wise, they are all doing one thing, putting an Age Gate verification on the website, either by verifying your birthday or getting the consent that you are above certain legal age.

But none of them are compliant in Canadian market.

In Canada, the legal age for purchasing certain products may vary between provinces. For example, the legal age to purchase cannabis in British Columbia is 18 but could be 19 in Alberta or 21 in Quebec. Therefore, a single birthday verification across board won’t be enough, nor is a simply Yes/No answer.

Phil, the author of the popular Age Gate plugin, shared an add-on in a WordPress support post that adds a dropdown list for all provinces for multiple age verification options. It works almost out of the box but does require a bit of adjustment to make it work on your own website.

There are only two files in the plugin:

  • age-gate-canadian-province.php and
  • select-dropdown.js.

There’s an array of the provinces with an age, just change these to match the legal needs. By default, Yukon is currently set to be 65! And you can use it mainly for test purpose.

province array in the PHP file

If you enabled the JavaScript version of the age gate, you don’t need to change anything in the JS file. But if you don’t, lines 17 and 19 need to be either removed or commented out.

lines that need to be commented out

By default, the Province dropdown list is located below the birthday selectors. If you need to move it up, replace the line 34 with the following line:

add_filter('pre_age_gate_custom_fields', 'ag_province_list', 10, 1);

After some styling twist, you should have a stylish age-gate that works perfectly in the Canadian market.

/Update on Oct. 21, 2020/

Phil commented that there is an updated addon that works out of the box. And thank you, Phil.

https://agegate.io/addons/age-gate-regions

4 thoughts on “WordPress Age Gate Verification for Canadian

  1. Hi to anyone finding this post, Phil the author of Age Gate here.

    Just wanted to point out that some of the steps above are probably no longer the best approach and have some flaws so probably best to avoid unless you’re happy to dig in and make updates where you need.

    If you don’t want to do that, there’s now a version of this that is supported over on agegate.io [link https://agegate.io/addons/age-gate-regions%5D that you can install and it’ll add settings to the CMS instead of fiddling around with files 🙂

    Thanks all!
    Phil

    1. Thanks Phil! I have been on the search for just this option for the last two days! Are we able to change the order in which the province and DOB input fields appear? Ideally, I would like to have the province selector appear first. Thanks in advance!

  2. Please disregard previous comment… I found the answer to my question in the documentation, I missed it the first time I read through. Thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *