Excellent software and practical tutorials
Email is rarely used in today's social environment. We prefer instant messaging. Email has become an advertising box or an independent third party. It is only used when retrieving passwords. The default comment function of WordPress requires an email address, which has become a step to increase user operation costs. How to remove this operation step and reduce user operation costs? If it is too troublesome to modify comments.php alone, and it is difficult to restore the changes after upgrading, use the comment_form_defaults filter, which is mainly used to modify the comment form created by the comment_form function (in the comments.php file line 2172)
The above method seems very complicated. Let’s change to a simpler modification method. Copy the following code and put it in functions.php of the current WordPress theme.
Select the theme editor in the appearance options of the WordPress background, select the init-functions.php template file in the theme functions directory and insert the following code. It's simple and convenient!
To delete the email option, modify the code as follows:
[cc lang="php"]
add_filter('comment_form_defaults','remove_email');
function remove_email($comment_form_html_arr){
//Delete the email text box
unset($comment_form_html_arr['fields']['email']);
//Modify the comment reminder content and remove email-related reminders.
$comment_form_html_arr['comment_notes_before'] = '<p class="comment-notes">'.sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' ).'</p>';
return $comment_form_html_arr;
}
Then you need to uncheck "Comment authors must fill in name and email address" in the discussion settings, otherwise the submission will fail!