rest_insert_comment
Fires after a comment is created or updated via the REST API.
Description
Parameters (3)
- 0. $comment (WP_Comment)
- Inserted or updated comment object.
- 1. $request (WP_REST_Request)
- Request object.
- 2. $true (bool) =>
true
- True when creating a comment, false when updating.
Usage
- To run the hook, copy the example below.
- // run the action
- do_action( 'rest_insert_comment', $comment, $request, $true );
- The following example is for adding a hook callback.
- // define the rest_insert_comment callback
- function action_rest_insert_comment( $comment, $request, $true ) {
- // make action magic happen here...
- };
- // add the action
- add_action( 'rest_insert_comment', 'action_rest_insert_comment', 10, 3 );
- To remove a hook callback, use the example below.
- // remove the action
- remove_action( 'rest_insert_comment', 'action_rest_insert_comment', 10, 3 );
Defined (2)
The action is defined in the following location(s).
- /wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
- do_action( 'rest_insert_comment', $comment, $request, true );
- do_action( 'rest_insert_comment', $comment, $request, false );