How to block Disqus cookies in WordPress

If you want to comply with cookies regulations, the EU GDPR in short , at this moment there is no other option but to report and block the cookies on your website until you obtain the user’s consent.

Well, not long ago I discovered the almost perfect GDPR and cookie management plugin, but Disqus cookies offered resistance and although they introduced improvements in the privacy management it was not enough, because the reality is that there is no way around it…

Or is it?

Well, yes, there is a solution, that problem is over from this very moment.

And the problem is over because we are going to look at the different alternatives we have to prevent Disqus cookies from loading until your web visitor accepts them.

How to prevent Disqus cookies from loading until consent is obtained

The easiest process to prevent Disqus cookies from loading until your visitors give their consent is to go through 3 steps, let’s do it.

Install the perfect GDPR and cookies WordPress plugin for free.

The first step is to install the GDPR Cookie Compliance plugin, and you don’t need to buy the paid license, you just only need the free version.

Once installed, configure it to your look and feel.

Anyway, here you have some screenshots of how I have configured it in the main screens, there is no mystery…

Enable consent for third party or additional cookies in the plugin

This step is essential, otherwise the last step will not work. You must activate this feature, putting your Analytics scripts in the boxes for this purpose, otherwise it will not let you save the changes and, consequently, activate it.

The problem with Disqus is that they don’t offer a script to insert in our web and be able to block it, and if there was, we would put it there and the problem would be solved, but no, they don’t offer it.

Nevertheless, do what i do and activate this.

In the header, body and footer boxes, place the script codes that you use, that for sure you have some, otherwise you wouldn’t be reading this, and save the changes.

And no, you don’t have to put anything from Disqus here, because there isn’t any, that’s the trick!

Add a function to block Disqus with third party cookies

Now that you have your GDPR and cookies plugin active, with the third party cookies, or additional ones, set up and tested to work, that actually block your cookies, add the following feature:

/* Block Disqus cookies in plugin GDPR Cookie Compliance */
add_action('comments_open', function( $comments_open ){
 if ( function_exists( 'gdpr_cookie_is_accepted' ) ) :
   /* tipos disponibles: 'strict', 'thirdparty', 'advanced' */
   if ( gdpr_cookie_is_accepted( 'thirdparty' ) ) :
      return $comments_open;
    else :
     return false;
 return $comments_open;
});Code language: PHP (php)

You have to add the code to the end of the active theme (child) functions.php file or to your (better) various customizations plugin, which you know I always recommend.

In the code you can, and in fact you must, change the cookie that must be accepted for Disqus to load, that in the example are the thirdparty ones, but if you prefer (like me) that they only load in the additional cookies, then you change it to advanced, or even if you want them to be accepted with the essential ones you change it to strict, you decide.

The difference will be with what consent the Disqus cookies will be loaded.

Now check again with your incognito browser for any post on your site and you will see that the Disqus cookies are not loaded until you give your consent.

This way, visiting any post on your site will not load anything but the session cookies, and even the Disqus comments won’t load, as if they didn’t exist.

But if you accept the pre-set cookies as we have seen…

The Disqus cookies will be loaded, and you will see the comment system.

In short: How to block cookies from Disqus

It’s three simple steps:

  1. Install the GDPR Cookie Compliance cookie plugin.
  2. Set up and activate the plugin and scripts.
  3. Add a function.

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top