钩子文档

rest_after_insert_comment

💡 云策文档标注

概述

rest_after_insert_comment 是一个 WordPress REST API 钩子,在通过 REST API 创建或更新评论后完全触发。它提供评论对象、请求对象和创建标志作为参数,用于执行后续操作。

关键要点

  • 触发时机:在通过 REST API 创建或更新评论后完全触发。
  • 参数:$comment(WP_Comment 对象)、$request(WP_REST_Request 对象)、$creating(布尔值,创建时为 true,更新时为 false)。
  • 用途:常用于在评论操作后执行自定义逻辑,如通知、日志记录或数据同步。
  • 相关函数:由 WP_REST_Comments_Controller::create_item() 和 WP_REST_Comments_Controller::update_item() 调用。
  • 版本历史:从 WordPress 5.0.0 版本引入。

📄 原文内容

Fires completely after a comment is created or updated via the REST API.

Parameters

$commentWP_Comment
Inserted or updated comment object.
$requestWP_REST_Request
Request object.
$creatingbool
True when creating a comment, false when updating.

Source

do_action( 'rest_after_insert_comment', $comment, $request, true );

Changelog

Version Description
5.0.0 Introduced.