[Resolved] Remove the check box "Save my name, email…" from comment area

Home Forums Support [Resolved] Remove the check box "Save my name, email…" from comment area

Home Forums Support Remove the check box "Save my name, email…" from comment area

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #579771
    Vitor

    Hi,

    I want to remove the check box that say “Save my name, email, and website in this browser for the next time I comment.” below the comment form. I already tried to hidden it but it left a big space between the submit button and the rest of the form. I’m not satisfy with the result so i want to remove from the comment template.

    Hopefully you guys can help me!

    #579835
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This checkbox was added in WP 4.9.6 and makes it so your comment forms are compatible with GDPR, which comes into effect on May 25th.

    If your site isn’t affected by GDPR, then you can remove it like this:

    add_filter( 'comment_form_default_fields', 'tu_comment_form_hide_cookies_consent' );
    function tu_comment_form_hide_cookies_consent( $fields ) {
    	unset( $fields['cookies'] );
    	return $fields;
    }

    I definitely suggest you read up on it, as there are some pretty heavy fines if the rules aren’t followed.

    #580013
    Vitor

    Hi again,
    First of all thanks for the help and the script works just fine ๐Ÿ™‚
    I researched a little about GDPR and i don’t want to remove the checkbox but instead edited, because i will only collect the name and the email from my readers and not their website.

    #580142
    Tom
    Lead Developer
    Lead Developer

    In that case you should be able to do something like this:

    add_filter( 'comment_form_default_fields', 'tu_comment_form_change_cookies_consent' );
    function tu_comment_form_change_cookies_consent( $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">Your modified text here</label></p>';
    	return $fields;
    }
    #580171
    Vitor

    Thanks again for your help. The problem is solved.

    #580316
    Tom
    Lead Developer
    Lead Developer

    No problem ๐Ÿ™‚

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.