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.

Leave a Reply

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