Thread Starter
Jellico
(@catsfoto1se)
Found a solution;
1. Turn off the Comment author must fill out name and email in the settings/discussion on your WordPress panel.
2. Add the following code (found on different sites and added them together)
function remove_website_email_field($fields)
{
$fields = array( $fields['author']); //add $fields['email'] for only website field
return $fields;
}
add_filter( 'comment_form_default_fields', remove_website_email_field );
function require_comment_name($fields) {
if ($fields['comment_author'] == '')
wp_die('Error: please enter a valid name.');
return $fields;
}
add_filter('preprocess_comment', 'require_comment_name');
to your functions.php file in your themes directory.
This will not only remove the email & website fields, it will also make the name field required even thou you turned it off in the settings.
(@catsfoto1se)
6 years, 1 month ago
I’ve found a question on this site with the same headline, but that evolved to an plug-in.
So I’m asking the same thing.
What do I need to do, to let visitor leave a comment by only providing a name and the comment (eg. Remove the email & website questions)?
I know that by adding this code:
to functions.php will eliminate the url question, but how do I remove the email question AND keep the name question?
}