Just an update (incase anyone else has similar needs). I think I found an easier solution to achieve the desired result.
I modified the list of locations in age-gate-canadian-province.php
Continuing from Yukon, I added the following
[
'age'=> 19,
'name' => 'Yukon'
],
[
'age'=> 100,
'name' => '--Outside Canada--'
],
[
'age'=> 18,
'name' => 'Africa'
],
[
'age'=> 18,
'name' => 'Asia'
],
[
'age'=> 18,
'name' => 'Australia'
],
[
'age'=> 19,
'name' => 'Europe'
],
[
'age'=> 19,
'name' => 'Latin America'
],
[
'age'=> 21,
'name' => 'United States'
]
];
This solution should satisfy our legal team for the time being.
Building out location specific options for this plugin would surely benefit many websites who want to stay compliant across multiple jurisdictions, and thus might be a good feature to consider integrating. Again, this is the only age verification plugin I’ve come across with this capability at the moment. Definitely sets it apart from others.
Thanks again for the great plugin.
follow up; this is still an issue I’m running into. Any assistance would be appreciated
the age “%s” set in messaging panel doesn’t update on the front-end when you select a different province. It always displays the default age, even though the actual age validation works correctly.
Plugin Author
Phil
(@philsbury)
Hi @aaronnb87,
Sorry for the slow reply on this. It’s definitely possible. Seems the canadian thing is actually quite popular, might roll it out into a proper plugin when I do the 3rd version of Age gate. Anyway…
In the canadian province plugin there’s a javascript file (select-dropdown.js), replace it’s contents with this and you should be sorted:
(function($){
function AgeGateProvince(){
this.init();
}
AgeGateProvince.prototype.init = function(){
$('#ag-province').on('change', this.updateAge.bind( this ) );
}
AgeGateProvince.prototype.updateAge = function(e){
var numericAge = atob(atob(e.target.value));
$('.age-gate-subheading').text($('.age-gate-subheading').text().replace(/\d+/g, numericAge));
$('.age-gate-message').text($('.age-gate-message').text().replace(/\d+/g, numericAge));
$('.age-gate-challenge').text($('.age-gate-challenge').text().replace(/\d+/g, numericAge));
$('input[name="age_gate[age]"]').val(e.target.value);
}
$(function(){
$(window).on('agegateshown', function(){
var provence = new AgeGateProvince();
});
});
})(jQuery);
The key parts are:
var numericAge = atob(atob(e.target.value));
$('.age-gate-subheading').text($('.age-gate-subheading').text().replace(/\d+/g, numericAge));
$('.age-gate-message').text($('.age-gate-message').text().replace(/\d+/g, numericAge));
$('.age-gate-challenge').text($('.age-gate-challenge').text().replace(/\d+/g, numericAge));
Where we look in the messages and replace the numbers. Could be an issue if there’s more numbers in the string, but that’s hopefully not the case.
Let me know if that works for you
Cheers
Phil
Hey @philsbury thanks for getting back to me on this. I modified the select-dropdown.js file in the Canadian plugin with the code you provided. I’ve cleared my cache, but it doesn’t seem to have made any change. If I select United States for instance, the message still shows 19 as the minimum age (despite defining it as 21 in the code I shared above).
I have “Use JavaScript Age Gate” checked btw.
Plugin Author
Phil
(@philsbury)
Hi @aaronnb87,
That’s odd, it should do. Did you clear server and browser cache?
Here’s a demo of it with made up ages, Alberta will be 18, Yukon 65 and everything else is 18:
http://demo.asylumdigital.net/
Thanks
Phil
Hey, I just tested again and it appears to be working now. must have been a cache issue. Thanks a lot.