将下面代码加入functions.php中即可。
// 禁止冒充博主评论 if(!is_user_logged_in()){ add_filter( 'preprocess_comment', 'admincheck' ); } function admincheck($incoming_comment) { $isSpam = 0; $admin_id = trim($incoming_comment['comment_author']); $admin_email = trim($incoming_comment['comment_author_email']); // 将以下代码中的 JV 改成博主昵称, 将 inlojv@qq.com 改成博主Email if ($admin_id == 'jv' || $admin_id == 'JV' || $admin_id == 'inlojv'|| $admin_id == 'INLOJV' || $admin_email == 'inlojv@qq.com') $isSpam = 1; if(!$isSpam) return $incoming_comment; wp_die('李鬼死远点!'); }
看注释主要判断条件:昵称为jv或JV或inlojv或INLOJV 或 邮箱为inlojv@qq.com 的评论表单值都禁止提交到数据库,直接返回错误提示!
WordPress
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。