groups_get_user_groups

Get the IDs of the groups of which a specified user is a member.

Description

(array) groups_get_user_groups( (int) $user_id = 0, (int) $pag_num = 0, (int) $pag_page = 0 ); 

Returns (array)

{ @type array $groups Array of groups returned by paginated query. @type int $total Count of groups matching query. }

Parameters (3)

0. $user_id — Optional. (int)
ID of the user.
1. $pag_num — Optional. (int)
Max number of results to return. Default: false (no limit).
2. $pag_page — Optional. (int)
Page offset of results to return. Default: false (no limit).

Usage

  1. if ( !function_exists( 'groups_get_user_groups' ) ) { 
  2. require_once '/bp-groups/bp-groups-functions.php'; 
  3.  
  4. // ID of the user. 
  5. $user_id = -1; 
  6.  
  7. // Optional. Max number of results to return. 
  8. // Default: false (no limit). 
  9. $pag_num = -1; 
  10.  
  11. // Optional. Page offset of results to return. 
  12. // Default: false (no limit). 
  13. $pag_page = -1; 
  14.  
  15. // NOTICE! Understand what this does before running. 
  16. $result = groups_get_user_groups($user_id, $pag_num, $pag_page); 
  17.  

Defined (1)

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

/bp-groups/bp-groups-functions.php  
  1. function groups_get_user_groups( $user_id = 0, $pag_num = 0, $pag_page = 0 ) { 
  2.  
  3. if ( empty( $user_id ) ) 
  4. $user_id = bp_displayed_user_id(); 
  5.  
  6. return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );