rest_preprocess_product_review

Prepare a single product review to be inserted into the database.

Description

(array|WP_Error) apply_filters( 'rest_preprocess_product_review', (unknown) $prepared_review, (unknown) $request ); 

Returns (array|WP_Error)

$prepared_review

Parameters (2)

0. $prepared_review (unknown)
The prepared review.
1. $request (unknown)
The request.

Usage

To run the hook, copy the example below.
  1. $prepared_review = apply_filters( 'rest_preprocess_product_review', $prepared_review, $request ); 
  2.  
  3. if ( !empty( $prepared_review ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the rest_preprocess_product_review callback 
  2. function filter_rest_preprocess_product_review( $prepared_review, $request ) { 
  3. // make filter magic happen here... 
  4. return $prepared_review
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'rest_preprocess_product_review', 'filter_rest_preprocess_product_review', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'rest_preprocess_product_review', 'filter_rest_preprocess_product_review', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/api/v1/class-wc-rest-product-reviews-controller.php  
  1. return apply_filters( 'rest_preprocess_product_review', $prepared_review, $request );