WordPress函数check_comment用于检测评论各字段,以判断是否为恶意评论。
check_comment( string $author, string $email, string $url, string $comment, string $user_ip, string $user_agent, string $comment_type ): bool
函数参数
$author
字符串
评论作者名称
字符串
评论作者邮箱
$url
字符串
评论作者网址
$comment
字符串
评论内容
$user_ip
字符串
评论作者IP地址
$user_agent
字符串
评论作者User-Agent
$comment_type
字符串
评论类型,comment、trackback、pingback
函数返回值
如果所有条件都检查通过,返回true,否则返回false。
在WordPress后台讨论设置中,可以设置一些检测条件:
- 如果勾选了“评论必须经人工批准”,无论其他条件如何都将返回false;
- 如果链接数超过设置的数量,则返回false;
- 如果任何参数内容包含不允许的单词,则返回false;
- 如果评论作者之前已获得批准,则评论将自动获得批准;
函数使用示例
扩展阅读
check_comment()函数位于:wp-includes/comment.php
相关函数:
- wp_allow_comment()
原创文章,作者:,如若转载,请注明出处:https://ce.771633.xyz/2051.html