有些人可能也想在WordPress评论留言但是填写电子邮件和姓名都懒的写感觉很讨厌至少我是这样的,现在教大家解决至少只留姓名不填电子邮件的方法。
(1)首先要在WP的设置-讨论-其它评论设置里勾选上“评论作者必须填写姓名和电子邮件”,然后修改WORDPRESS根目录下的wp-comments-post.php。
(2)找到以下代码:
if ( get_option(‘require_name_email’) && !$user->ID ) {
if ( 6 > strlen($comment_author_email) || ” == $comment_author )
wp_die( __(‘Error: please fill the required fields (name, email).’) );
elseif ( !is_email($comment_author_email))
wp_die( __(‘Error: please enter a valid email address.’) );
}
if ( 6 > strlen($comment_author_email) || ” == $comment_author )
wp_die( __(‘Error: please fill the required fields (name, email).’) );
elseif ( !is_email($comment_author_email))
wp_die( __(‘Error: please enter a valid email address.’) );
}
更换成:
if ( get_option(‘require_name_email’) && !$user->ID ) {
if ( ” == $comment_author )
wp_die( __(‘有误:请留下您的称谓.’) );
if ( “” != $comment_author_email) {
if ( !is_email($comment_author_email))
wp_die( __(‘有误:邮件格式不正确.’) );
}
}
if ( ” == $comment_author )
wp_die( __(‘有误:请留下您的称谓.’) );
if ( “” != $comment_author_email) {
if ( !is_email($comment_author_email))
wp_die( __(‘有误:邮件格式不正确.’) );
}
}