How to Completely Remove Name/Email From Comment Form

How to Completely Remove Name/Email From Comment Form

This is for those users who want to completely remove name and email fields from their comment form, below is the little piece of code that you’ll need to paste in your theme’s functions.php file or a site specific plugin.

function wpb_alter_comment_form_fields($fields) {
unset($fields['author']);
unset($fields['email']);
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'wpb_alter_comment_form_fields');

Should your comment form be showing Your email address will not be published text, then you can hide it by editing your theme’s comments.php file. Locate the tag

<?php comment_form ?>
 and replace it with this code:
</pre>
<?php

comment_form(array(

'comment_notes_before' => '<p class="comment-notes">' . __( 'No name or email address required.' ) . ( $req ? $required_text : '' ) . '</p>'

));

?>

If you can not locate the comment_form, then you can still hide this text by adding this CSS to your theme or child theme‘s style.css file.

Read: How to display WordPress Comments Counts

</pre>
.comment-notes {

display:none;

}

Word of Caution about Anonymous Comments                     

Please note that without the name and email address as required fields, your comment form will attract a high number of spam comments. While Akismet and Sucuri may block some bad IPs, I’ll also recommend that you put a captcha verification to prevent some of that.

Read: How to Re-arrange WordPress Comments

 

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Related Post

Also Read  Wordpress Basics For Beginners

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu
×

Cart

Spelling error report

The following text will be sent to our editors: