Someone asked me to remove Email and Website field from WordPress comment section, So their reader can easily publish comments without filling these extra fields. You have also seen many sites don’t have website/ URL box in the comment section. Previous we have also written to remove website field.
But Here we are going to also remove email field as well as website field from comment form. This is the easiest way to do this..
How to Remove Email and Website Field from WordPress Comment
Just follow the bellow steps.
- First Login to Your WordPress dashboard.
- Go to Appearance>Editor
- And here Found the file name Functions.PhpÂ
- Open it and go to bottom.
- Paste the bellow code just before ?>
function remove_comment_fields($fields) {
unset($fields['email']);
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'remove_comment_fields');
- Now save the file and check your site. (Please remove cache files).
Note: In some WordPress Themes, Code is not working properly. First, try the above one, If this code is not working for you then you can also try this one.
function custom_validate_comment_author() {
if( empty( $_POST['author'] ) || ( !preg_match( '/[^\s]/', $_POST['author'] ) ) )
wp_die( __('Error: Please enter your name') );
}
add_action( 'pre_comment_on_post', 'custom_validate_comment_author' );
This code makes comment author field to be required, though in fact comments are anonymous without an email.
Next Thing to Do After Using This Code:
Do not forget this, after using the above codes. By default WordPress enabledÂ
How you can do this, Just follow bellow steps.
- Go to Settings>Discussion.
- Here you see Other comment settings.
- Simply uncheck the Comment author must fill out name and email.
- And in Comment Moderation section , just set the number 1. So when any spammer adds HTML link to the message. it will not be published on your site. And you can manually approve or mark as spam.
We hope this guide help you to Remove Email and Website Field from WordPress Comment section.
I would like to edit the comment form so that it only asks name, no email, no comment, no url, and also to edit the form so that prompts appear in my language. Do you think that is possible?
I was looking for this only as i need to remove these fields and i am going to remove them now. It was seriously very helpful. Thanx a lot keep sharing such informative articles.
nice blog i love this article