Add permissions for count endpoints
This commit is contained in:
parent
2af47c6699
commit
017e7cee1d
|
@ -148,7 +148,8 @@ class WC_API_Coupons extends WC_API_Resource {
|
|||
|
||||
$query = $this->query_coupons( $filter );
|
||||
|
||||
// TODO: permissions?
|
||||
if ( ! current_user_can( 'read_private_shop_coupons' ) )
|
||||
return new WP_Error( 'woocommerce_api_user_cannot_read_coupons_count', __( 'You do not have permission to read the coupons count', 'woocommerce' ), array( 'status' => 401 ) );
|
||||
|
||||
return array( 'count' => (int) $query->found_posts );
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ class WC_API_Customers extends WC_API_Resource {
|
|||
$query = $this->query_customers( $filter );
|
||||
|
||||
if ( ! current_user_can( 'list_users' ) )
|
||||
return new WP_Error( 'woocommerce_api_user_cannot_read_customer', __( 'You do not have permission to read customers', 'woocommerce' ), array( 'status' => 401 ) );
|
||||
return new WP_Error( 'woocommerce_api_user_cannot_read_customers_count', __( 'You do not have permission to read the customers count', 'woocommerce' ), array( 'status' => 401 ) );
|
||||
|
||||
return array( 'count' => count( $query->get_results() ) );
|
||||
}
|
||||
|
|
|
@ -249,7 +249,8 @@ class WC_API_Orders extends WC_API_Resource {
|
|||
|
||||
$query = $this->query_orders( $filter );
|
||||
|
||||
// TODO: permissions?
|
||||
if ( ! current_user_can( 'read_private_shop_orders' ) )
|
||||
return new WP_Error( 'woocommerce_api_user_cannot_read_orders_count', __( 'You do not have permission to read the orders count', 'woocommerce' ), array( 'status' => 401 ) );
|
||||
|
||||
return array( 'count' => (int) $query->found_posts );
|
||||
}
|
||||
|
|
|
@ -136,7 +136,8 @@ class WC_API_Products extends WC_API_Resource {
|
|||
if ( ! empty( $type ) )
|
||||
$filter['type'] = $type;
|
||||
|
||||
// TODO: permissions?
|
||||
if ( ! current_user_can( 'read_private_products' ) )
|
||||
return new WP_Error( 'woocommerce_api_user_cannot_read_products_count', __( 'You do not have permission to read the products count', 'woocommerce' ), array( 'status' => 401 ) );
|
||||
|
||||
$query = $this->query_products( $filter );
|
||||
|
||||
|
|
Loading…
Reference in New Issue