Hi @harlointeractive,
You can filter it to not include search. There’s two ways you can do this and which one you choose comes down to your setup.
Option 1: PHP
You can add the following snippet to you functions.php (or custom plugin)
This will work in both PHP (see below for caveat) and Javascript modes of the plugin
add_filter('age_gate_restricted', function ($restrict, $data) {
if (isset($data->type) && $data->type === 'search') {
return false;
}
return $restrict;
}, 10, 2);
Option 2: Javascript
This is only available in the Javascript version.
First you need to enable hooks in the Age Gate Advanced settings.
Then in a javascript file you can add:
ageGateHooks.addFilter('age_gate_restricted', 'demo', function(restrict, data) {
if(data.type === 'search') {
return false;
}
return restrict;
});
Or, if you don’t have access to any JS files, you can add it to the footer of the page:
add_action('wp_footer', function () {
?>
<script>
ageGateHooks.addFilter('age_gate_restricted', 'demo', function(restrict, data) {
if(data.type === 'search') {
return false;
}
return restrict;
});
</script>
<?php
});
While the pure PHP version will work for JS mode, it does an Ajax request, this is obviously an additional server call you may not want, and could delay age gate showing if there’s lots of queries happening. Essentially, the JS method is probably better if you’re using the JS age gate.
Thanks
Phil