Automattic\WooCommerce\Admin\Features\Blueprint
RestApi::check_permission()
Check if the current user has permission to perform the request.
Method of the class: RestApi{}
No Hooks.
Return
true|false|\WP_Error
.
Usage
$RestApi = new RestApi(); $RestApi->check_permission();
RestApi::check_permission() RestApi::check permission code WC 9.7.1
public function check_permission() { if ( ! current_user_can( 'install_plugins' ) ) { return new \WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); } return true; }