Support Forum Support Forum GDPR Cookie Compliance Add cookie decline function in the cookie banner text “Click here to decline”

Topic Resolution: Resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Avatarsrajwade
    March 05, 2020 @ 5:04 pm

    Hi! I have a WordPress site which uses GDPR Cookie Compliance plugin. I wanted to know if it’s possible to call the gdpr_info_add_reject_button_extensions function on the cookie banner text which says ‘Click here to decline’, instead of adding a button on the banner which says ‘I decline’ or I reject’ to reject the cookie usage.
    When user clicks on ‘decline’ it should perform the same function as the reject button would.

    Thanks for all the help!

    March 06, 2020 @ 12:25 pm

    Can you please help me with this functionality? I need to add cookie decline functionality to the text on the banner and not on the ‘I Decline’ button. Is it possible to implement this functionality?

    Moove AgencyMoove Agency
    March 06, 2020 @ 2:45 pm

    Hi srajwade,

    Thanks for using our plugins.

    The requested feature is not implemented in our plugin yet, the reject feature it works only on the button inside the GDPR Banner.

    The following code snippet, should be added to functions.phph, could help to achieve the reject feature on custom links by using class: gdpr-reject-link

    		document.addEventListener('click', function (event) {
    			// If the clicked element doesn't have the right selector, bail
    			if ( !'.gdpr-reject-link') ) return;
    			// Don't follow the link
    			document.cookie = 'moove_gdpr_popup = '+JSON.stringify({strict: '1', thirdparty: '0', advanced: '0'})+'0; path=/; SameSite=Lax';
    		}, false);

    The code snippet above will requires gdpr-reject-link to be added as a Class to your link.

    Hope this helps.

    March 06, 2020 @ 3:13 pm


    Thank you for the quick response. really appreciate it. This function definitely helps and resolves my issue. Thank you 🙂
    Your plugin is great!

    However, just for the sake of understanding, I tried the following approach before adding your function to the functions.php file.
    1. Added ‘Click [decline]here[/decline] to decline’ in my text banner, in the same way that you have implemented the [setting]settings[/setting] functionality
    2. Provided the class=”mgbutton moove-gdpr-infobar-reject-btn” to the $content
    3. And on clicking ‘here’ on the banner, it seemed that did the trick and I could see the decline cookies functionality working
    Do you think this approach could work too?

    Thank you again!

    Moove AgencyMoove Agency
    March 10, 2020 @ 1:54 pm

    Hi srajwade,

    Thanks for your comments.

    Unfortunately, the shortcode is working for settings screen only. You can enable the “text” tab in the cookie banner editor by using the following code snippet, and you can add the class:

    		.moove_gdpr_table_form_holder #moove_gdpr_info_bar_content-html, 
    		.moove_gdpr_table_form_holder #moove_gdpr_info_bar_content-tmce {
    			display: block;

    We might implement the [decline][/decline] shortcode in a future release.


    March 11, 2020 @ 2:56 pm


    Thank you for your help.
    1. I added your ‘gdpr-reject-link’ function in my functions.php file
    2. I added the code below, the same way you have added the [settings][/settings] shortcode and called the class ‘gdpr-reject-link’

    //for decline cookie link
    $content = str_replace( '[decline]', '<span data-href="" class="gdpr-reject-link">', $content );
    $content = str_replace( '[/decline]', '</span>', $content );

    3. Added – ‘Click [decline]here[/decline] to decline’ in the cookie banner settings
    This definitely works and when user clicks on ‘here’, it does not track the GA cookies. However, I am afraid that on upgrading the GDPR cookie compliance plugin in future might cause my addition on [decline[/decline] shortcode to go away since I added this shortcode in the class-gdpr-modules.php

    GDPR Cookie Compliance plugin and your gdpr-reject-link function definitely works for me. No complaints there 🙂
    Just need to be sure of the above mentioned issue, if I have to upgrade plugin in future.

    Thank you again!

    Moove AgencyMoove Agency
    March 12, 2020 @ 8:25 am

    Hi srajwade,

    Please note, our plugin is extended with hooks and actions, we would recommend using these hooks to change the functionality and you can get updates in the future.
    In the plugin folder (gdpr-cookie-compliance) you can see the gdpr-modules folder, by moving this to your theme / child-theme folder, you can make changes in the layout without touching the plugin. The Cookie Banner (info bar) template is in gdpr-modules/infobar/infobar-base.php

    Hope this helps.

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