bp_get_current_blog_roles

Return an array of roles from the currently loaded blog.

Description

(object) bp_get_current_blog_roles(); 

WordPress roles are dynamically flipped when calls to switch_to_blog() and restore_current_blog() are made, so we use and trust WordPress core to have loaded the correct results for us here. As enhancements are made to WordPress's RBAC, so should our capability functions here.

Returns (object)


Usage

  1. if ( !function_exists( 'bp_get_current_blog_roles' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-caps.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_get_current_blog_roles(); 
  7.  

Defined (1)

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

/bp-core/bp-core-caps.php  
  1. function bp_get_current_blog_roles() { 
  2. global $wp_roles; 
  3.  
  4. // Sanity check on roles global variable. 
  5. $roles = isset( $wp_roles->roles ) 
  6. ? $wp_roles->roles 
  7. : array(); 
  8.  
  9. /** 
  10. * Filters the list of editable roles. 
  11. * @since 2.1.0 
  12. * @param array $roles List of roles. 
  13. */ 
  14. $roles = apply_filters( 'editable_roles', $roles ); 
  15.  
  16. /** 
  17. * Filters the array of roles from the currently loaded blog. 
  18. * @since 2.1.0 
  19. * @param array $roles Available roles. 
  20. * @param WP_Roles $wp_roles Object of WordPress roles. 
  21. */ 
  22. return apply_filters( 'bp_get_current_blog_roles', $roles, $wp_roles );