WC_REST_V4_Controller::check_permissions
Check permissions for a given request.
Метод класса: WC_REST_V4_Controller{}
Хуков нет.
Возвращает
bool|WP_Error.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->check_permissions( $request, $permission );
- $request(WP_REST_Request) (обязательный)
- Full details about the request.
- $permission(строка)
- The permission to check for.
По умолчанию:'read'
Код WC_REST_V4_Controller::check_permissions() WC REST V4 Controller::check permissions WC 11.2.2
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;
}