How to add consent checkbox in comment section

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>',

Questions:

  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.

Leave a Comment