wc_rest_check_product_reviews_permissions()
Check product reviews permissions on REST API.
Hooks from the function
Return
true|false
.
Usage
wc_rest_check_product_reviews_permissions( $context, $object_id );
- $context(string)
- Request context.
Default: 'read' - $object_id(string)
- Object ID.
Changelog
Since 3.5.0 | Introduced. |
wc_rest_check_product_reviews_permissions() wc rest check product reviews permissions code WC 9.4.2
function wc_rest_check_product_reviews_permissions( $context = 'read', $object_id = 0 ) { $permission = false; $contexts = array( 'read' => 'moderate_comments', 'create' => 'edit_products', 'edit' => 'edit_products', 'delete' => 'edit_products', 'batch' => 'edit_products', ); if ( $object_id > 0 ) { $object = get_comment( $object_id ); if ( ! is_a( $object, 'WP_Comment' ) || get_comment_type( $object ) !== 'review' ) { return false; } } if ( isset( $contexts[ $context ] ) ) { $permission = current_user_can( $contexts[ $context ], $object_id ); } return apply_filters( 'woocommerce_rest_check_permissions', $permission, $context, $object_id, 'product_review' ); }