本文整理自网络,侵删。
写了一年多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');
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');
标签:WordPress
相关阅读 >>
wordpress自动给文章添加nofollow属性的实现方法
在centos系统上从零开始搭建wordpress博客的全流程记录
更多相关阅读请进入《wordpress》频道 >>