apply_filters( ‘rest_pre_insert_comment’, array|WP_Error $prepared_comment, WP_REST_Request $request )

In this article

Filters a comment before it is inserted via the REST API.

Description

Allows modification of the comment right before it is inserted via wp_insert_comment() .
Returning a WP_Error value from the filter will short-circuit insertion and allow skipping further processing.

Parameters

$prepared_commentarray|WP_Error
The prepared comment data for wp_insert_comment() .
$requestWP_REST_Request
Request used to insert the comment.

Source

$prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );

Changelog

VersionDescription
4.8.0$prepared_comment can now be a WP_Error to short-circuit insertion.
4.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.