Allow people who have commets approved to submit a non-Chinese comment.
No miscarriage of justice any more.
允许"曾在本站发表过评论且通过了审核"的用户发表纯英文评论, 妈妈再也不用担心我的误判.
灵感来自于wordpress默认讨论选项中的"评论者先前须有评论通过了审核"这一项, 我在wp-includes/comments.php中找到了相关动作, 此动作在
get_option('comment_whitelist')
后触发, 我觉得可以用在纯英文评论上
以上是废话, 以下代码扔到functions.php
/**
* allow old users to submit english comments
* coder: xiaohudie
* 2013-05-20
*/
function butterfly_en($comment) {
$pattern = '/[一-龥]/u';
$ccontent = htmlspecialchars($comment['comment_content']);
$cau=$comment['comment_author'] ;
$cem=$comment['comment_author_email'] ;
global $wpdb;
$ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$cau' AND comment_author_email = '$cem' and comment_approved = '1' LIMIT 1");
if( is_user_logged_in() || 1 == $ok_to_comment ){ return $comment; }
elseif ( !preg_match_all($pattern, $ccontent, $match) ) {
exit('sorry, please type some Chinese words like 小蝴蝶最漂亮 in your comment to pass the spam-check.');
}
else{return $comment; }
}
add_filter('preprocess_comment', 'butterfly_en');
大家可以尽情测试, 测试方法(前提你之前在小蝴蝶评论过):
你可以成功的提交一条纯英文评论了, 不会英文的同学可以复制这一句: smallbutterfly is very beautiful
然后你可以改一下你的昵称, 然后再发一条纯英文评论试试
allow_english_comment is coded by http://xiaohudie.net. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl. -
small butterfly和little butterfly 是不一样的概念哦!
papapa~
bigbutterfly is very beautiful
wo bu hui ying wen za ban a ? ni kan ming bai wo shuo sha le ma ? qin ! qi shi wo yi zhi an lian ni.
@SEO博客 我是文盲不会汉语拼音
Can really do?看来不行
@海蓝 废话因为不是老用户
@小蝴蝶 俺不是来很多回了嘛
@海蓝 你以前又不是这个昵称..
@小蝴蝶 这样啊 那好吧 我就用新面孔跟博主问个好吧
Nothing happened…
对不起,为了防垃圾评论,评论内容中必须带有中文字符.
在自己的主题测试不行,任何评论都禁止了……
@figo 写丢了一个参数,已经修改过来,现在你试试一定可以了
@小蝴蝶 ok
smallbutterfly is very beautiful