wc_modify_editable_roles

Modify the list of editable roles to prevent non-admin adding admin users.

Description

(array) wc_modify_editable_roles( (array) $roles ); 

Returns (array)

Parameters (1)

0. $roles (array)
The roles.

Usage

  1. if ( !function_exists( 'wc_modify_editable_roles' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-user-functions.php'; 
  3.  
  4. // The roles. 
  5. $roles = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_modify_editable_roles($roles); 
  9.  

Defined (1)

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

/includes/wc-user-functions.php  
  1. function wc_modify_editable_roles( $roles ) { 
  2. if ( ! current_user_can( 'administrator' ) ) { 
  3. unset( $roles['administrator'] ); 
  4. return $roles;