bbp_get_caps_for_role

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

Description

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

Returns (array)

Capabilities for $role

Parameters (1)

0. $role — Optional. (string) => ''
Defaults to The role to load caps for

Usage

  1. if ( !function_exists( 'bbp_get_caps_for_role' ) ) { 
  2. require_once '/includes/core/capabilities.php'; 
  3.  
  4. // Optional. Defaults to The role to load caps for 
  5. $role = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_caps_for_role($role); 
  9.  

Defined (1)

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

/includes/core/capabilities.php  
  1. function bbp_get_caps_for_role( $role = '' ) { 
  2.  
  3. // Which role are we looking for? 
  4. switch ( $role ) { 
  5.  
  6. // Keymaster 
  7. case bbp_get_keymaster_role() : 
  8. $caps = array( 
  9.  
  10. // Keymasters only 
  11. 'keep_gate' => true,  
  12.  
  13. // Primary caps 
  14. 'spectate' => true,  
  15. 'participate' => true,  
  16. 'moderate' => true,  
  17. 'throttle' => true,  
  18. 'view_trash' => true,  
  19.  
  20. // Forum caps 
  21. 'publish_forums' => true,  
  22. 'edit_forums' => true,  
  23. 'edit_others_forums' => true,  
  24. 'delete_forums' => true,  
  25. 'delete_others_forums' => true,  
  26. 'read_private_forums' => true,  
  27. 'read_hidden_forums' => true,  
  28.  
  29. // Topic caps 
  30. 'publish_topics' => true,  
  31. 'edit_topics' => true,  
  32. 'edit_others_topics' => true,  
  33. 'delete_topics' => true,  
  34. 'delete_others_topics' => true,  
  35. 'read_private_topics' => true,  
  36.  
  37. // Reply caps 
  38. 'publish_replies' => true,  
  39. 'edit_replies' => true,  
  40. 'edit_others_replies' => true,  
  41. 'delete_replies' => true,  
  42. 'delete_others_replies' => true,  
  43. 'read_private_replies' => true,  
  44.  
  45. // Topic tag caps 
  46. 'manage_topic_tags' => true,  
  47. 'edit_topic_tags' => true,  
  48. 'delete_topic_tags' => true,  
  49. 'assign_topic_tags' => true 
  50. ); 
  51.  
  52. break; 
  53.  
  54. // Moderator 
  55. case bbp_get_moderator_role() : 
  56. $caps = array( 
  57.  
  58. // Primary caps 
  59. 'spectate' => true,  
  60. 'participate' => true,  
  61. 'moderate' => true,  
  62. 'throttle' => true,  
  63. 'view_trash' => true,  
  64.  
  65. // Forum caps 
  66. 'publish_forums' => true,  
  67. 'edit_forums' => true,  
  68. 'read_private_forums' => true,  
  69. 'read_hidden_forums' => true,  
  70.  
  71. // Topic caps 
  72. 'publish_topics' => true,  
  73. 'edit_topics' => true,  
  74. 'edit_others_topics' => true,  
  75. 'delete_topics' => true,  
  76. 'delete_others_topics' => true,  
  77. 'read_private_topics' => true,  
  78.  
  79. // Reply caps 
  80. 'publish_replies' => true,  
  81. 'edit_replies' => true,  
  82. 'edit_others_replies' => true,  
  83. 'delete_replies' => true,  
  84. 'delete_others_replies' => true,  
  85. 'read_private_replies' => true,  
  86.  
  87. // Topic tag caps 
  88. 'manage_topic_tags' => true,  
  89. 'edit_topic_tags' => true,  
  90. 'delete_topic_tags' => true,  
  91. 'assign_topic_tags' => true,  
  92. ); 
  93.  
  94. break; 
  95.  
  96. // Spectators can only read 
  97. case bbp_get_spectator_role() : 
  98. $caps = array( 
  99.  
  100. // Primary caps 
  101. 'spectate' => true,  
  102. ); 
  103.  
  104. break; 
  105.  
  106. // Explicitly blocked 
  107. case bbp_get_blocked_role() : 
  108. $caps = array( 
  109.  
  110. // Primary caps 
  111. 'spectate' => false,  
  112. 'participate' => false,  
  113. 'moderate' => false,  
  114. 'throttle' => false,  
  115. 'view_trash' => false,  
  116.  
  117. // Forum caps 
  118. 'publish_forums' => false,  
  119. 'edit_forums' => false,  
  120. 'edit_others_forums' => false,  
  121. 'delete_forums' => false,  
  122. 'delete_others_forums' => false,  
  123. 'read_private_forums' => false,  
  124. 'read_hidden_forums' => false,  
  125.  
  126. // Topic caps 
  127. 'publish_topics' => false,  
  128. 'edit_topics' => false,  
  129. 'edit_others_topics' => false,  
  130. 'delete_topics' => false,  
  131. 'delete_others_topics' => false,  
  132. 'read_private_topics' => false,  
  133.  
  134. // Reply caps 
  135. 'publish_replies' => false,  
  136. 'edit_replies' => false,  
  137. 'edit_others_replies' => false,  
  138. 'delete_replies' => false,  
  139. 'delete_others_replies' => false,  
  140. 'read_private_replies' => false,  
  141.  
  142. // Topic tag caps 
  143. 'manage_topic_tags' => false,  
  144. 'edit_topic_tags' => false,  
  145. 'delete_topic_tags' => false,  
  146. 'assign_topic_tags' => false,  
  147. ); 
  148.  
  149. break; 
  150.  
  151. // Participant/Default 
  152. case bbp_get_participant_role() : 
  153. default : 
  154. $caps = array( 
  155.  
  156. // Primary caps 
  157. 'spectate' => true,  
  158. 'participate' => true,  
  159.  
  160. // Forum caps 
  161. 'read_private_forums' => true,  
  162.  
  163. // Topic caps 
  164. 'publish_topics' => true,  
  165. 'edit_topics' => true,  
  166.  
  167. // Reply caps 
  168. 'publish_replies' => true,  
  169. 'edit_replies' => true,  
  170.  
  171. // Topic tag caps 
  172. 'assign_topic_tags' => true,  
  173. ); 
  174.  
  175. break; 
  176.  
  177. return apply_filters( 'bbp_get_caps_for_role', $caps, $role );