WordPress检测评论函数:check_comment

WordPress函数check_comment用于检测评论各字段,以判断是否为恶意评论。

check_comment( string $author, string $email, string $url, string $comment, string $user_ip, string $user_agent, string $comment_type ): bool

函数参数

$author

字符串

评论作者名称

$email

字符串

评论作者邮箱

$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

Like (0)
Previous 2025年3月8日
Next 2025年3月8日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注