Automattic\WooCommerce\Admin\API
MobileAppQRLogin::get_items_permissions_check
Check whether the current user can generate a QR login token.
Requires the manage_woocommerce capability, which covers administrators and shop managers out of the box. The check is deliberately explicit (not routed through wc_rest_check_manager_permissions()) so it cannot be loosened by the woocommerce_rest_check_permissions that other Admin API endpoints share.
Method of the class: MobileAppQRLogin{}
No Hooks.
Returns
\WP_Error|true|false. True if the user has the required capability, WP_Error otherwise.
Usage
$MobileAppQRLogin = new MobileAppQRLogin(); $MobileAppQRLogin->get_items_permissions_check( $request );
- $request(required)
- .
MobileAppQRLogin::get_items_permissions_check() MobileAppQRLogin::get items permissions check code WC 11.0.1
public function get_items_permissions_check( $request ) {
unset( $request );
// Parameter required by WP REST contract but unused here.
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return new \WP_Error(
'woocommerce_rest_cannot_view',
__( 'Sorry, you are not allowed to generate a mobile app QR login token.', 'woocommerce' ),
array( 'status' => rest_authorization_required_code() )
);
}
return true;
}