钩子文档

wp_set_comment_status

💡 云策文档标注

概述

wp_set_comment_status 是一个 WordPress 动作钩子,在数据库中更新评论状态并从对象缓存中移除评论后立即触发,但在所有状态转换钩子之前执行。

关键要点

  • 触发时机:在评论状态从一种转换为另一种后,数据库更新完成且评论已从对象缓存移除时,早于其他状态转换钩子。
  • 参数:$comment_id(评论ID,作为数字字符串)和 $comment_status(当前评论状态,可能值包括 'hold'、'0'、'approve'、'1'、'spam'、'trash')。
  • 相关函数:与 wp_set_comment_status() 和 wp_delete_comment() 函数关联,用于设置或删除评论状态。
  • 版本历史:自 WordPress 1.5.0 版本引入。

📄 原文内容

Fires immediately after transitioning a comment’s status from one to another in the database and removing the comment from the object cache, but prior to all status transition hooks.

Parameters

$comment_idstring
Comment ID as a numeric string.
$comment_statusstring
Current comment status. Possible values include 'hold', '0', 'approve', '1', 'spam', and 'trash'.

Source

do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status );

Changelog

Version Description
1.5.0 Introduced.