WordPress禁止评论内容中的超链接

本文作者: Fengjiajun 评论数量: 0

WordPress,是垃圾邮件、垃圾评论经常光顾的一个系统。下面的代码将会屏蔽评论内容中的超链接:

function wp_comment_post( $incoming_comment ) {
$http = '/[href="|rel="nofollow"|http:\/\/|<\/a>]/u';
if(preg_match($http, $incoming_comment['comment_content'])) {
err( "禁止发链接地址!" );
}
return( $incoming_comment );
}
add_filter('preprocess_comment', 'wp_comment_post');

专注 Wordpress Woocommerce 独立站开发&谷歌广告推广 8 年

免费提供WordPress建站以及谷歌广告推广相关咨询服务

This will close in 0 seconds