WC_REST_V4_Controller::check_permissions
Check permissions for a given request.
Method of the class: WC_REST_V4_Controller{}
No Hooks.
Returns
true|false|WP_Error.
Usage
// protected - for code of main (parent) or child class $result = $this->check_permissions( $request, $permission );
- $request(WP_REST_Request) (required)
- Full details about the request.
- $permission(string)
- The permission to check for.
Default: 'read'
WC_REST_V4_Controller::check_permissions() WC REST V4 Controller::check permissions code WC 10.3.6
protected function check_permissions( $request, $permission = 'read' ) {
if ( ! wc_rest_check_manager_permissions( 'settings', $permission ) ) {
return new WP_Error(
'woocommerce_rest_cannot_' . $permission,
__( 'Sorry, you are not allowed to perform this action.', 'woocommerce' ),
array( 'status' => rest_authorization_required_code() )
);
}
return true;
}