ngg_get_sorted_roles

The NextGEN Gallery ngg get sorted roles function.

Description

ngg_get_sorted_roles(); 

Usage

  1. if ( !function_exists( 'ngg_get_sorted_roles' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/admin/roles.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ngg_get_sorted_roles(); 
  7.  

Defined (1)

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

/products/photocrati_nextgen/modules/ngglegacy/admin/roles.php  
  1. function ngg_get_sorted_roles() { 
  2. // This function returns all roles, sorted by user level (lowest to highest) 
  3. global $wp_roles; 
  4. $roles = $wp_roles->role_objects; 
  5. $sorted = array(); 
  6.  
  7. if( class_exists('RoleManager') ) { 
  8. foreach( $roles as $role_key => $role_name ) { 
  9. $role = get_role($role_key); 
  10. if( empty($role) ) continue; 
  11. $role_user_level = array_reduce(array_keys($role->capabilities), array('WP_User', 'level_reduction'), 0); 
  12. $sorted[$role_user_level] = $role; 
  13. $sorted = array_values($sorted); 
  14. } else { 
  15. $role_order = array("subscriber", "contributor", "author", "editor", "administrator"); 
  16. foreach($role_order as $role_key) { 
  17. $sorted[$role_key] = get_role($role_key); 
  18. return $sorted;