Plugin Author
Phil
(@philsbury)
Hi @johncmorris74,
As you’re using the JS version, there’s a couple of steps but it’s possible.
First, go to the Age Gate advanced settings and enable the “JS Hooks” option.
You can then access some filters in javascript, but you can make it happen in PHP:
add_action('wp_footer', function () {
?>
<script>
ageGateHooks.addFilter('age_gate_restricted', 'namespace', function(show){
var params = new URLSearchParams(window.location.search);
if (params.has('bypass')) {
return false;
}
return show;
});
</script>
<?php
}, 1);
just change the bypass parameter to be whatever you want it to be.
Cheers
Phil
Hey Phil,
Thanks for that bit of code it did the trick! But when I navigate to another page the age gate shows. They want the cookie remembered so age gate won’t show on any pages. What could I add to get that to happen?
Plugin Author
Phil
(@philsbury)
Hi @johncmorris74,
Adding document.cookie = "age_gate=" + 21 + "" + "; path=/"; in the if statement should do it. Full snippet:
add_action('wp_footer', function () {
?>
<script>
ageGateHooks.addFilter('age_gate_restricted', 'namespace', function(show){
var params = new URLSearchParams(window.location.search);
if (params.has('bypass')) {
document.cookie = "age_gate=" + 21 + "" + "; path=/";
return false;
}
return show;
});
</script>
<?php
}, 1);
Thanks
Phil
-
This reply was modified 4 years, 5 months ago by
Phil.
That indeed did the trick! Thanks a TON Phil! Have a great evening!