Hi there,
we would like to supress the cookie modal on specific pages (e.g. privacy policy and imprint).
We already tried to hide it with CSS but this is not working as expected and should be the last solution.
Is there any chance to “override” the function “get_cookie_consent_message_bar_option” or to set the “avia_get_option” return value for selected page IDs?
Thank you in advance
Hey kisys,
Thank you for the inquiry.
This snippet should disable the cookie consent message bar on certain pages.
add_action('wp', function() {
global $avia, $post;
if(in_array($post->ID, array(12, 15, 347))) {
$avia->options['avia']['cookie_consent'] = '';
}
}, 10);
current_theme_supports( 'avia_gdpr_permanent_hide_message_bar' );
In the array, place the id of the page or pages, separated by comma, where the consent bar should not be displayed.
if(in_array($post->ID, array(12, 15, 347))) {
Best regards,
Ismael
Dear Ismael,
sorry for the late reply, haven’t seen your answer, sadly.
We solved it a bit different but will give your solution a try as well:
function remove_cookie_bar_on_specific_pages() {
$searchInUrl = array(
'imprint',
'data-protection',
'cookie-information',
);
if (preg_match('/'.implode('|', $searchInUrl).'/', $_SERVER['REQUEST_URI'])) {
wp_dequeue_script( 'avia-cookie-js' );
wp_dequeue_style( 'avia-cookie-css' );
}
}
add_action( 'wp_print_scripts' , 'remove_cookie_bar_on_specific_pages', 999 );
Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon