bp_get_caps_for_role

Return an array of capabilities based on the role that is being requested.

Description

(array) bp_get_caps_for_role( (string) $role = '' ); 

Returns (array)

Capabilities for $role.

Parameters (1)

0. $role — Optional. (string) => ''
The role for which you're loading caps.

Usage

  1. if ( !function_exists( 'bp_get_caps_for_role' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-caps.php'; 
  3.  
  4. // The role for which you're loading caps. 
  5. $role = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_get_caps_for_role($role); 
  9.  

Defined (1)

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

/bp-core/bp-core-caps.php  
  1. function bp_get_caps_for_role( $role = '' ) { 
  2.  
  3. // Which role are we looking for? 
  4. switch ( $role ) { 
  5.  
  6. // Administrator. 
  7. case 'administrator' : 
  8. $caps = array( 
  9. // Misc. 
  10. 'bp_moderate',  
  11. ); 
  12.  
  13. break; 
  14.  
  15. // All other default WordPress blog roles. 
  16. case 'editor' : 
  17. case 'author' : 
  18. case 'contributor' : 
  19. case 'subscriber' : 
  20. default : 
  21. $caps = array(); 
  22. break; 
  23.  
  24. /** 
  25. * Filters the array of capabilities based on the role that is being requested. 
  26. * @since 1.6.0 
  27. * @param array $caps Array of capabilities to return. 
  28. * @param string $role The role currently being loaded. 
  29. */ 
  30. return apply_filters( 'bp_get_caps_for_role', $caps, $role );