So you are curious about the new checkbox with label “save my name email and website in this browser for the next time i comment”. This checkbox comes under commends fields while user is not logged in. Actually this is just helpful for users who want to do interaction on your website’s posts.
Since WordPress 4.9.6 this checkbox is by default part of comments form on each WordPress’s comments form. This is actually GDPR (General Data Protection Regulation). Which means you need to take permission from users before you save their data as cookies into browser for your website. Also its implemented since 25 May 2018.
Before WordPress used to save commented data automatically on browser. So next time user comment on same website they do not need to re enter same information. But now its required that’s why you see this checkbox.
How to remove Checkbox Save my name email and website in this browser
While GDPR does isn’t required for all countries but its mandatory for EU union countries. In case your website operate outside Europe and there is no interaction for users from Europe you can take out this checkbox.
So how to disable the checkbox Save my name email and website in this browser for the next time i comment. Just add the code below in your theme’s functions.php file and the checkbox will be disabled.
add_filter( 'comment_form_default_fields', 'wc_comment_form_hide_cookies' );
function wc_comment_form_hide_cookies( $fields ) {
unset( $fields['cookies'] );
return $fields;
}
As you know the checkbox is not required field and does not validate on server side or even on front end. Either you can hide checkbox with CSS if you are worry about editing functions.php for any reason or you are not using child theme for a theme which is expected to update in future.
How to Edit or Update Label for Checkbox Save my name email and website in this browser
When someone try to comment on your WordPress website while they are not logged in. They will see a checkbox in their comment form with label “save my name email and website in this browser for the next time i comment”. There are several reasons you might want to change it to some simple words, or in your own language. Or you want to say some cool stuff with checkbox to save cookie. In our case we want to say Remember me.
Just add the code below make sure you change Remember me! to anything you want to edit or replace label to.
add_filter( 'comment_form_default_fields', 'wc_comment_form_change_cookies' );
function wc_comment_form_change_cookies( $fields ) {
$commenter = wp_get_current_commenter();
$consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
$fields['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">'.__('Remember Me!', 'textdomain').'</label></p>';
return $fields;
}
Make sure to change textdomain with your theme’s text domain in case you want to support Multi language or loco translation of your strings.
If this post helped you to either remove, edit or update “save my name email and website in this browser for the next time i comment”. Please rate our post or leave us a feedback if you have good suggestions. Thanks
1 Comment
You have tell so easily of my problem , I am just lying on the bed on Best Mattress For Back and reading your article. I read and understand it so easily and quickly. Keep posted like this article which very simple to understand.