wc_modify_editable_roles()
Modify the list of editable roles to prevent non-admin adding admin users.
Hooks from the function
Return
Array
.
Usage
wc_modify_editable_roles( $roles );
- $roles(array) (required)
- Roles.
wc_modify_editable_roles() wc modify editable roles code WC 9.4.2
function wc_modify_editable_roles( $roles ) { if ( is_multisite() && is_super_admin() ) { return $roles; } if ( ! wc_current_user_has_role( 'administrator' ) ) { unset( $roles['administrator'] ); if ( wc_current_user_has_role( 'shop_manager' ) ) { $shop_manager_editable_roles = apply_filters( 'woocommerce_shop_manager_editable_roles', array( 'customer' ) ); return array_intersect_key( $roles, array_flip( $shop_manager_editable_roles ) ); } } return $roles; }