rest_pre_insert_product_review
Filter a product review (comment) before it is inserted via the REST API.
Allows modification of the comment right before it is inserted via wp_insert_comment.
Usage
add_filter( 'rest_pre_insert_product_review', 'wp_kama_rest_pre_insert_product_review_filter', 10, 2 );
/**
* Function for `rest_pre_insert_product_review` filter-hook.
*
* @param array $prepared_review The prepared comment data for `wp_insert_comment`.
* @param WP_REST_Request $request Request used to insert the comment.
*
* @return array
*/
function wp_kama_rest_pre_insert_product_review_filter( $prepared_review, $request ){
// filter...
return $prepared_review;
}
- $prepared_review(array)
- The prepared comment data for
wp_insert_comment. - $request(WP_REST_Request)
- Request used to insert the comment.
Where the hook is called
rest_pre_insert_product_review
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-product-reviews-v1-controller.php 300
$prepared_review = apply_filters( 'rest_pre_insert_product_review', $prepared_review, $request );