wordpress如何过滤不包含中文垃圾评论,比如英文评论、日文垃圾等。下面web建站一下小编给大家简单介绍一下具体代码!
在当前主题的functions.php文件中新增以下代码:
复制代码function check_comment_data( $commnet_data ) {
$pattern = "/[x7f-xff]/";
// 禁用全英文评论
if(!preg_match($pattern, $commnet_data['comment_content'])) {
$str = "您的评论中必须包含中文!";
die ( __( $str ) );
//wp_die( $str );
}
return $commnet_data;
}
add_filter('preprocess_comment', 'check_comment_data');
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
WordPress版本如何使用str_starts_with和str_ends_with函数
wordpress教程如何输出用于回复评论的隐藏输入html
标签: wordpress函数, wordpress垃圾评论, wordpress过滤
上面是“wordpress如何过滤不包含中文垃圾评论(禁止全英文评论)”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3753.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!