woocommerce_rest_pre_insert_product_review
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.
Использование
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(массив|WP_Error)
- The prepared review data for wp_insert_comment().
- $request(WP_REST_Request)
- Request used to insert the review.
Список изменений
С версии 3.5.0 | Введена. |
Где вызывается хук
woocommerce_rest_pre_insert_product_review
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-reviews-controller.php 458
$prepared_review = apply_filters( 'woocommerce_rest_pre_insert_product_review', $prepared_review, $request );