bb_can_access_tab

The BuddyPress bb can access tab function.

Description

bb_can_access_tab( $profile_tab, $viewer_id, $owner_id ); 

Parameters (3)

0. $profile_tab
The profile tab.
1. $viewer_id
The viewer id.
2. $owner_id
The owner id.

Usage

  1. if ( !function_exists( 'bb_can_access_tab' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; 
  3.  
  4. // The profile tab. 
  5. $profile_tab = null; 
  6.  
  7. // The viewer id. 
  8. $viewer_id = null; 
  9.  
  10. // The owner id. 
  11. $owner_id = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_can_access_tab($profile_tab, $viewer_id, $owner_id); 
  15.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-core.php  
  1. function bb_can_access_tab( $profile_tab, $viewer_id, $owner_id ) { 
  2. global $bb_current_user; 
  3. $viewer_id = (int) $viewer_id; 
  4. $owner_id = (int) $owner_id; 
  5. if ( $viewer_id == bb_get_current_user_info( 'id' ) ) 
  6. $viewer =& $bb_current_user; 
  7. else 
  8. $viewer = new BP_User( $viewer_id ); 
  9. if ( !$viewer ) 
  10. return '' === $profile_tab[2]; 
  11.  
  12. if ( $owner_id == $viewer_id ) { 
  13. if ( '' === $profile_tab[1] ) 
  14. return true; 
  15. else 
  16. return $viewer->has_cap($profile_tab[1]); 
  17. } else { 
  18. if ( '' === $profile_tab[2] ) 
  19. return true; 
  20. else 
  21. return $viewer->has_cap($profile_tab[2]);