写了一年多WordPress,除了感受到它的强大,还有spam…
虽然Akismet阻挡了四五K的spam,但是一条一条审核还是太过麻烦,写个方法来处理一下
复制代码代码如下:
function spamCheck( $incoming_comment ) {
$pattern = '/[一-龥]/u';
if(!preg_match($pattern, $incoming_comment['comment_content'])) {
wp_die( 'You should type some Chinese word!' );
}
if(substr_count($incoming_comment['comment_content'],'http') > 3) {
wp_die( '请勿在您的评论中包含过多链接!' );
}
return( $incoming_comment );
}
add_filter('preprocess_comment', 'spamCheck');
关键字词: