WordPress

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

edge

View Comments

  • 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

    • 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!

  • 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!

Share
Published by
edge

Recent Posts

Disable Copilot on Windows 11 via Group Policy GPO

If using Copilot right from the Taskbar isn't your thing, you should disable it. Even…

7 months ago

Setting Default Fonts in Word, Excel, Outlook, and PowerPoint via Group Policy

In an environment where standardizing things does matter, setting default fonts in Microsoft Office apps…

8 months ago

Wake-On-LAN (WOL) with Windows and PowerShell

Wake-On-LAN is a networking standard that lets you wake up a computer from either a…

8 months ago

How To Remove Restrictions Set in A Password-Protected PDF File

First of all, this is not to bypass a PDF file that requires a password…

8 months ago

How To Move My Outlook Navigation Bar Back From Left Back To the Bottom

Microsoft has been lurking about the idea of placing the Outlook navigation bar to the…

2 years ago

Headset with Microphone Echoing My Own Voice on Windows, What To Do?

One colleague came up to me the other day asking me to take look at…

2 years ago