bp_forums_filter_caps

Map WordPress caps onto bbPress users, to ensure that they can post.

Description

(array) bp_forums_filter_caps( (array) $allcaps ); 

Returns (array)

Caps array with bbPress caps added.

Parameters (1)

0. $allcaps (array)
Array of capabilities.

Usage

  1. if ( !function_exists( 'bp_forums_filter_caps' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bp-forums-functions.php'; 
  3.  
  4. // Array of capabilities. 
  5. $allcaps = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_forums_filter_caps($allcaps); 
  9.  

Defined (1)

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

/bp-forums/bp-forums-functions.php  
  1. function bp_forums_filter_caps( $allcaps ) { 
  2. global $wp_roles, $bb_table_prefix; 
  3.  
  4. if ( !bp_loggedin_user_id() ) 
  5. return $allcaps; 
  6.  
  7. $bb_cap = bp_get_user_meta( bp_loggedin_user_id(), $bb_table_prefix . 'capabilities', true ); 
  8.  
  9. if ( empty( $bb_cap ) ) 
  10. return $allcaps; 
  11.  
  12. $bb_cap = array_keys($bb_cap); 
  13. $bb_cap = $wp_roles->get_role( $bb_cap[0] ); 
  14. $bb_cap = $bb_cap->capabilities; 
  15.  
  16. return array_merge( (array) $allcaps, (array) $bb_cap );