Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1192850

    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

    #1194299

    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

    #1207510

    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 );
    #1207675

    Hi,

    Did you need additional help with this topic or shall we close?

    Best regards,
    Jordan Shannon

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.