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