trashed_comment
云策文档标注
概述
trashed_comment 是一个 WordPress 动作钩子,在评论被移至回收站后立即触发。它提供了评论 ID 和评论对象作为参数,方便开发者执行相关操作。
关键要点
- 触发时机:评论被发送到回收站后立即执行
- 参数:$comment_id(评论 ID,字符串类型)和 $comment(WP_Comment 对象,代表被移至回收站的评论)
- 版本历史:从 WordPress 2.9.0 引入,4.9.0 版本添加了 $comment 参数
- 相关函数:与 wp_trash_comment() 函数关联,用于移动评论到回收站
注意事项
- 此钩子适用于需要在评论被移至回收站时执行自定义逻辑的场景,如清理相关数据或发送通知
- 确保在回调函数中正确处理 $comment 参数,以访问评论的详细信息
原文内容
Fires immediately after a comment is sent to Trash.
Parameters
$comment_idstring-
The comment ID as a numeric string.
$commentWP_Comment-
The trashed comment.
Source
do_action( 'trashed_comment', $comment->comment_ID, $comment );