woocommerce_rest_pre_insert_product_review filter-hookWC 3.5.0

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

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

Usage

add_filter( 'woocommerce_rest_pre_insert_product_review', 'wp_kama_woocommerce_rest_pre_insert_product_review_filter', 10, 2 );

/**
 * Function for `woocommerce_rest_pre_insert_product_review` filter-hook.
 * 
 * @param array|WP_Error  $prepared_review The prepared review data for wp_insert_comment().
 * @param WP_REST_Request $request         Request used to insert the review.
 *
 * @return array|WP_Error
 */
function wp_kama_woocommerce_rest_pre_insert_product_review_filter( $prepared_review, $request ){

	// filter...
	return $prepared_review;
}
$prepared_review(array|WP_Error)
The prepared review data for wp_insert_comment().
$request(WP_REST_Request)
Request used to insert the review.

Changelog

Since 3.5.0 Introduced.

Where the hook is called

WC_REST_Product_Reviews_Controller::create_item()
woocommerce_rest_pre_insert_product_review
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-reviews-controller.php 443
$prepared_review = apply_filters( 'woocommerce_rest_pre_insert_product_review', $prepared_review, $request );

Where the hook is used in WooCommerce

Usage not found.