The below code snippet will allow you to make any cookie category a strictly necessary category using GDPR Cookie Consent Plugin. The user cannot disable the categories that are strictly necessary from the settings pop-up.
To achieve this:
- From your WordPress dashboard, go to Appearance > Theme editor.
- Then, add the below given code snippet at the bottom end of functions.php of the active theme file.
- You can replace ‘functional’, ‘others’ from the below code with the category slug that you want as strictly enabled.
Luisa
April 1, 2022
Hello,
When I add a translation to the NECESSARY cookies, it shows the category but it also shows the button that allows you to disable it. How can I fix the issue?
Thanks
Mark
April 18, 2022
Hi @ Luisa,
Greetings from Webtoffee!
Please keep the slug name of the ‘Necessary’ category as ‘Necessary’ itself so that always enabled status will be shown in the place of the toggle button.
Cedric
March 4, 2022
Hi Safwana and/or Mark!
I use the 2.1.1 free version of this really good plugin and I wanted to add the “Always enabled” cookies option.
I found this page but I’m not an encoder so where is precisely “Enter the name of the category in the single quotes”?
Is it at the place of “skroutz” or ”pixel“ or both or elsewhere? Could you help me please?
Mark
April 26, 2022
Hi Cedric,
We have updated the article to have a more familiar name for the sample category names in the code. As you can see now in the article, please replace the ‘functional’ or ‘others’ with your category slugs. If you need to set for only one category, you need to use only one.
Antonio
October 25, 2021
Hello,
is the plugin compatible with TranslatePress or WeGlot?
Thank you
Antonio
Mark
October 31, 2021
Hi Antonia,
Currently, the plugin is tested with WPML, Polylang, Qtranslate, Locotranslate etc. Translatepress and Weglot aren’t supported at the moment as they have a different method for string translation.
Dominique Müller
July 2, 2021
Hi Safwana. I have also a multilanguage site managed by the Polylang plugin and the Salient Theme. I do not have a function.php, but a functions.php. When I add the code into it and edit the ‘skroutz’ and ‘pixel’ to my new categorys, nothing happen. At the front end the the user can still change the category to disable. What do I make wrong?
I have the latest update from Salient, GDPR Cookie Consent Plugin and WordPress installed and all work fine.
Thanks for your help in advance.
Mark
July 6, 2021
Hi Dominique,
Assuming that you are using the premium version of the plugin, this code snippet is no longer needed. You can go to Cookie Category > click edit on the category you want to modify and tick the ‘Make strictly enabled’ option.
Didier Vairac-Pradel
April 23, 2021
Hi, thank you for this pluggin.
I have an issue. I copy/paste this code in the function.php of the child and the enabled/disabled option just disapear in the backend (category list) but the user still can change the option.*
Have you got and Idea to help me ?
Thanks
Best regards
Didier
Mark
April 25, 2021
Hi,
Please let us know which version of the plugin are you using.
saxina
April 23, 2022
I have the same issue. I am using GDPR Cookie consent Version 2.1.1
please provide support,
thanks
Mark
May 2, 2022
Hi Saxena,
Please share the code snippet you added and your site URL via the support forum here.
Yannick Sanchez
April 28, 2020
Hi Safwana, I have a multi lingual site managed by a Polylang plugin. I added the php code and it is working well only for my english categories. Unfortunately this is not working for my French translations, which are can still editable in the front end even if they are listed in the script.
Could you please assist regarding this matter?
Yannick Sanchez
April 28, 2020
Problem resolved, it was due to accents on my category. As a workaround I edited my category with a name without accents.