Action hook 'rest_insert_comment'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php at line 902

View Source

rest_insert_comment

Action Hook
Description
Updates a comment.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php View on GitHub
Hook Type Action
Line Number 902

Hook Parameters

Type Name Description
WP_REST_Request $request Full details about the request.

Usage Examples

Basic Usage
<?php
// Hook into rest_insert_comment
add_action('rest_insert_comment', 'my_custom_function', 10, 1);

function my_custom_function($request) {
    // Your custom code here
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:902 - How this hook is used in WordPress core
<?php
 897  		}
 898  
 899  		$comment = get_comment( $id );
 900  
 901  		/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
 902  		do_action( 'rest_insert_comment', $comment, $request, false );
 903  
 904  		$schema = $this->get_item_schema();
 905  
 906  		if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
 907  			$meta_update = $this->meta->update_value( $request['meta'], $id );

PHP Documentation

<?php
/**
	 * Updates a comment.
	 *
	 * @since 4.7.0
	 *
	 * @param WP_REST_Request $request Full details about the request.
	 * @return WP_REST_Response|WP_Error Response object on success, or error object on failure.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Related Hooks

Related hooks will be displayed here in future updates.