To fulfil the GDPR policy, I want to add a consent checkbox under the "Post Comment" section.

I have followed the WpBeginner tutorial and put the following code in my Comment.php file

// Now we will add our new privacy checkbox optin
        'cookies' => '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
                                         '<label for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label></p>',


  1. The above code is putting a checkbox but I am not sure if its really doing the required thing (not storing data if unchecked).

  2. The checkbox is not placed correctly as shown in the screenshot below. How can I change the position to put it in the correct place?

enter image description here

PS: I am using Activello theme.


1 Answer 1


The 'consent' checkbox is already part of WP Core. See Settings, Discussion, for the "Show comments cookies opt-in checkbox". Enable that, and your comments area will have a GDPR-type checkbox there.

There are also other Privacy/GDPR related options in the latest WP. Look under Settings, Privacy. Also look under the Tools menu for the Export/Erase Personal Data screens to take care of removing personal information.

You should also add the Privacy page to your menu/site. More info here: https://wordpress.org/news/2018/04/gdpr-compliance-tools-in-wordpress/ .

Note that there are tons of GDPR-related plugins. I made a simple one here: https://wordpress.org/plugins/simple-gdpr/ . It's not fancy, but will get the basics on your site if you are not EU based.

  • thanks, but still the location of Checkbox does not look correct. I actually want to remove the Website URL field and when I do so then, the Consent Checkbox appears like that at a weird position.
    – skm
    Commented Aug 25, 2018 at 20:35
  • You could do it with CSS, but you could try simply dropping a <br> tag, for a line break, in front of <p class="comment-form.....
    – De Coder
    Commented Aug 25, 2018 at 21:06
  • The positioning of the added checkbox might be affected by how the theme is creating the comment form. You may need to adjust the CSS for the added checkbox. Or modify your code to match how the theme is presenting the fields (using their CSS class names). Assuming that you are adding your code in a Child Theme via it's functions.php, so that a theme update won't overwrite your code. You can also use the comment_form_default_fields filter to add fields to the comment form. But that depends on whether the theme is using standard WP functions to display the comment form. Commented Aug 25, 2018 at 23:20
  • @RickHellewell: thanks. I am EU based so, can I still use your plugin or can you recommend another plugin for GDPR.
    – skm
    Commented Aug 26, 2018 at 8:32
  • All my plugin does is display a notice on every page until the user clicks OK. It doesn't do anything else, no process for deleting/reporting on things, but WP has stuff for that. No forms to ask for info, etc. Just a popup banner on all pages; no opt out (if you want to visit the site, then you agree to tracking/storage of info). It also lets you define a privacy page, and will create the privacy page with some generic text. The readme has info about the popup code, and where I got the privacy text. Simple, as the title says. Works fine for basic sites. Check it out; might be OK for you. Commented Aug 26, 2018 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.