• Resolved christian70

    (@christian70)


    I’m using GDPR Cookie Compliance Plugin along with WP Rocket Cache. Two of my favourite and most useful plugins.

    I need to show different content according to the cookies choices (i.e.: show YouTube videos if third-party cookies are accepted or a picture with warning if they are not).

    So I used the native PHP hooks:
    if ( gdpr_cookie_is_accepted( 'thirdparty' ) ) { ... } else { ... }
    and then force page reload:
    add_action( 'gdpr_force_reload', '__return_true' )

    Unfortunately it doen’t work if caching is enabled.
    I wonder if there’s a way to load uncached page, for example by adding a specific query string to the url before reloading and using that query string as exception in cache settings.

    Any suggestion to make the plugins work together will be highly appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter christian70

    (@christian70)

    Ok I realized that WP Rocket Cache gives the possibility to create different cached versions of the same pages according to the value of a cookie. This is a solution.

    Another one could be to use Ajax in order to load different template parts according to the value of moove_gdpr_popup cookie. About that, how to ckeck if third-party cookies have been accepted in JS?

    I saw Javascript consent variables in documentation but I didn’t understand how to use them…

    Plugin Author Moove Agency

    (@mooveagency)

    Hi @christian70

    Thanks for using our plugins.

    Our plugin has the following 3 consent variables implemented by default for each cookie category:

    gdpr_consent__strict => values: true or false
    gdpr_consent__thirdparty => values: true or false
    gdpr_consent__advanced => values: true or false

    You also have a single variable that includes all categories that the user accepted:

    gdpr_consent__cookies => values: strict|thirdparty|advanced or strict|thirdparty or strict|advanced

    These consent variables can be used to configure your WP Rocket Cache and can be read using javascript.

    Hope this helps.

    Thread Starter christian70

    (@christian70)

    Do you mean:

    $(document).ready(function(){
       if (gdpr_consent__thirdparty = true) {
         do something...
       }
    });

    ?
    Because it doesn’t work, it can’t read the correct value if I change my cookies choice and reload the page.

    • This reply was modified 2 years, 5 months ago by christian70.
    Thread Starter christian70

    (@christian70)

    The point is that the values of gdpr_consent__thirdparty or gdpr_consent__cookies are cached. So they are useless in order to print different content according to them. The only way I found is to get directly the values of the cookie moove_gdpr_popup that is updated via Ajax.

    Plugin Author Moove Agency

    (@mooveagency)

    Hi @christian70

    You are right, WP Rocket caches our cookie. To prevent this, the “moove_gdpr_popup” cookie needs to be excluded from caching in WPRocket -> Advanced Rules -> Never Cache Cookies.

    More details:
    https://www.dropbox.com/s/9i4lnlpc14neywb/Screenshot_2022-06-10_at_13.32.44.png?dl=0

    Hope this helps.

    Thread Starter christian70

    (@christian70)

    Sorry but this is not an option: if I exclude “moove_gdpr_popup” cookie from caching, all pages and all posts, the whole content of the site is not cached. So there’s no sense in using a cache plugin. Ajax is the only solution working for me.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP Rocket Cache’ is closed to new replies.