bp_group_is_member

Check if current user is member of a group.

Description

bp_group_is_member( (bool) $group = false ); 

Parameters (1)

0. $group — Optional. (bool) => false
Group to check is_member. Default: current group in the loop.

Usage

  1. if ( !function_exists( 'bp_group_is_member' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-groups/bp-groups-template.php'; 
  3.  
  4. // Optional. Group to check is_member. 
  5. // Default: current group in the loop. 
  6. $group = false; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_group_is_member($group); 
  10.  

Defined (1)

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

/bp-groups/bp-groups-template.php  
  1. function bp_group_is_member( $group = false ) { 
  2. global $groups_template; 
  3.  
  4. // Site admins always have access. 
  5. if ( bp_current_user_can( 'bp_moderate' ) ) { 
  6. return true; 
  7.  
  8. if ( empty( $group ) ) { 
  9. $group =& $groups_template->group; 
  10.  
  11. /** 
  12. * Filters whether current user is member of a group. 
  13. * @since 1.2.4 
  14. * @since 2.5.0 Added the `$group` parameter. 
  15. * @param bool $is_member If user is a member of group or not. 
  16. * @param object $group Group object. 
  17. */ 
  18. return apply_filters( 'bp_group_is_member', ! empty( $group->is_member ), $group );