bbp_get_dynamic_roles

Fetch a filtered list of forum roles that the current user is allowed to have.

Description

(array) bbp_get_dynamic_roles(); 

Simple function who's main purpose is to allow filtering of the list of forum roles so that plugins can remove inappropriate ones depending on the situation or user making edits.

Specifically because without filtering, anyone with the edit_users capability can edit others to be administrators, even if they are only editors or authors. This filter allows admins to delegate user management.

Returns (array)


Usage

  1. if ( !function_exists( 'bbp_get_dynamic_roles' ) ) { 
  2. require_once '/includes/core/capabilities.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_get_dynamic_roles(); 
  7.  

Defined (1)

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

/includes/core/capabilities.php  
  1. function bbp_get_dynamic_roles() { 
  2. return (array) apply_filters( 'bbp_get_dynamic_roles', array( 
  3.  
  4. // Keymaster 
  5. bbp_get_keymaster_role() => array( 
  6. 'name' => __( 'Keymaster', 'bbpress' ),  
  7. 'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() ) 
  8. ),  
  9.  
  10. // Moderator 
  11. bbp_get_moderator_role() => array( 
  12. 'name' => __( 'Moderator', 'bbpress' ),  
  13. 'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() ) 
  14. ),  
  15.  
  16. // Participant 
  17. bbp_get_participant_role() => array( 
  18. 'name' => __( 'Participant', 'bbpress' ),  
  19. 'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) 
  20. ),  
  21.  
  22. // Spectator 
  23. bbp_get_spectator_role() => array( 
  24. 'name' => __( 'Spectator', 'bbpress' ),  
  25. 'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() ) 
  26. ),  
  27.  
  28. // Blocked 
  29. bbp_get_blocked_role() => array( 
  30. 'name' => __( 'Blocked', 'bbpress' ),  
  31. 'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() ) 
  32. ) );