wc_rest_check_manager_permissions

Check manager permissions on REST API.

Description

wc_rest_check_manager_permissions( (string) $object, (string) $context = 'read' ); 

Parameters (2)

0. $object (string)
The object.
1. $context — Optional. (string) => 'read'
Request context.

Usage

  1. if ( !function_exists( 'wc_rest_check_manager_permissions' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-rest-functions.php'; 
  3.  
  4. // The object. 
  5. $object = ''; 
  6.  
  7. // Request context. 
  8. $context = 'read'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_rest_check_manager_permissions($object, $context); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-rest-functions.php  
  1. function wc_rest_check_manager_permissions( $object, $context = 'read' ) { 
  2. $objects = array( 
  3. 'reports' => 'view_woocommerce_reports',  
  4. 'settings' => 'manage_woocommerce',  
  5. 'system_status' => 'manage_woocommerce',  
  6. 'attributes' => 'manage_product_terms',  
  7. 'shipping_methods' => 'manage_woocommerce',  
  8. 'payment_gateways' => 'manage_woocommerce',  
  9. ); 
  10.  
  11. $permission = current_user_can( $objects[ $object ] ); 
  12.  
  13. return apply_filters( 'woocommerce_rest_check_permissions', $permission, $context, 0, $object );