钩子文档

comment_{$old_status}_to_{$new_status}

💡 云策文档标注

概述

这是一个 WordPress 钩子,在评论状态从特定旧状态转换到特定新状态时触发。钩子名称是动态的,基于旧状态和新状态。

关键要点

  • 钩子名称格式为 comment_{$old_status}_to_{$new_status},其中 $old_status 和 $new_status 是评论的旧状态和新状态。
  • 可能的钩子名称示例包括 comment_unapproved_to_approved、comment_spam_to_approved 等。
  • 参数为 $comment,类型为 WP_Comment 对象。
  • 由 wp_transition_comment_status() 函数调用,用于处理评论状态转换。
  • 自 WordPress 2.7.0 版本引入。

📄 原文内容

Fires when the comment status is in transition from one specific status to another.

Description

The dynamic portions of the hook name, $old_status, and $new_status, refer to the old and new comment statuses, respectively.

Possible hook names include:

  • comment_unapproved_to_approved
  • comment_spam_to_approved
  • comment_approved_to_unapproved
  • comment_spam_to_unapproved
  • comment_unapproved_to_spam
  • comment_approved_to_spam

Parameters

$commentWP_Comment
Comment object.

Source

do_action( "comment_{$old_status}_to_{$new_status}", $comment );

Changelog

Version Description
2.7.0 Introduced.