translate_level_to_role

Translate user level to user role name.

Description

(string) translate_level_to_role( (int) $level ); 

Returns (string)

User role name.

Parameters (1)

0. $level (int)
User level.

Usage

  1. if ( !function_exists( 'translate_level_to_role' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/upgrade.php'; 
  3.  
  4. // User level. 
  5. $level = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = translate_level_to_role($level); 
  9.  

Defined (1)

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

/wp-admin/includes/upgrade.php  
  1. function translate_level_to_role($level) { 
  2. switch ($level) { 
  3. case 10: 
  4. case 9: 
  5. case 8: 
  6. return 'administrator'; 
  7. case 7: 
  8. case 6: 
  9. case 5: 
  10. return 'editor'; 
  11. case 4: 
  12. case 3: 
  13. case 2: 
  14. return 'author'; 
  15. case 1: 
  16. return 'contributor'; 
  17. case 0: 
  18. return 'subscriber';