deleted_comment
云策文档标注
概述
deleted_comment 是一个 WordPress 动作钩子,在评论从数据库中被删除后立即触发。它主要用于在评论删除时执行自定义操作,例如清理相关数据或记录日志。
关键要点
- 触发时机:评论从数据库删除后立即执行。
- 参数:$comment_id(评论 ID,字符串类型)和 $comment(被删除的 WP_Comment 对象)。
- 版本历史:从 WordPress 2.9.0 引入,4.9.0 版本添加了 $comment 参数。
- 相关函数:与 wp_delete_comment() 函数关联,用于处理评论的删除或移至垃圾箱。
原文内容
Fires immediately after a comment is deleted from the database.
Parameters
$comment_idstring-
The comment ID as a numeric string.
$commentWP_Comment-
The deleted comment.
Source
do_action( 'deleted_comment', $comment->comment_ID, $comment );