钩子文档

edit_comment

💡 云策文档标注

概述

edit_comment 是一个 WordPress 动作钩子,在评论更新到数据库后立即触发。它主要用于在评论数据修改时执行自定义操作。

关键要点

  • 触发时机:评论更新到数据库后立即触发,且在评论状态转换钩子之前。
  • 参数:$comment_id(评论ID,整数类型)和 $data(评论数据,数组类型)。
  • 相关函数:与 wp_update_comment() 函数关联,用于更新数据库中的评论。
  • 版本历史:从 WordPress 1.2.0 引入,4.6.0 版本添加了 $data 参数。

代码示例

do_action( 'edit_comment', $comment_id, $data );

注意事项

开发者应确保钩子回调函数正确处理 $comment_id 和 $data 参数,以避免数据不一致或性能问题。


📄 原文内容

Fires immediately after a comment is updated in the database.

Description

The hook also fires immediately before comment status transition hooks are fired.

Parameters

$comment_idint
The comment ID.
$dataarray
Comment data.

Source

do_action( 'edit_comment', $comment_id, $data );

Changelog

Version Description
4.6.0 Added the $data parameter.
1.2.0 Introduced.