WC_REST_Customer_Downloads_V1_Controller::get_items_permissions_check() public WC 1.0
Check whether a given request has permission to read customers.
{} It's a method of the class: WC_REST_Customer_Downloads_V1_Controller{}
No Hooks.
Return
WP_Error|true/false.
Usage
$WC_REST_Customer_Downloads_V1_Controller = new WC_REST_Customer_Downloads_V1_Controller(); $WC_REST_Customer_Downloads_V1_Controller->get_items_permissions_check( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Code of WC_REST_Customer_Downloads_V1_Controller::get_items_permissions_check() WC REST Customer Downloads V1 Controller::get items permissions check WC 5.0.0
public function get_items_permissions_check( $request ) {
$customer = get_user_by( 'id', (int) $request['customer_id'] );
if ( ! $customer ) {
return new WP_Error( 'woocommerce_rest_customer_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
}
if ( ! wc_rest_check_user_permissions( 'read', $customer->get_id() ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}