woocommerce_rest_customer_allowed_roles
Filter the allowed roles for the REST API.
Danger: Make sure that the roles listed here cannot manage the shop.
Usage
add_filter( 'woocommerce_rest_customer_allowed_roles', 'wp_kama_woocommerce_rest_customer_allowed_roles_filter' ); /** * Function for `woocommerce_rest_customer_allowed_roles` filter-hook. * * @param array $roles Array of allowed roles. * * @return array */ function wp_kama_woocommerce_rest_customer_allowed_roles_filter( $roles ){ // filter... return $roles; }
- $roles(array)
- Array of allowed roles.
Changelog
Since 9.5.2 | Introduced. |
Where the hook is called
woocommerce_rest_customer_allowed_roles
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-customers-v1-controller.php 156
return apply_filters( 'woocommerce_rest_customer_allowed_roles', array( 'customer', 'subscriber' ) );