BP_Groups_Member::get_invites( int $user_id, int|bool $limit = false, int|bool $page = false, string|array|bool $exclude = false )

Get a user’s outstanding group invitations.

Description

Parameters

$user_id

(Required) ID of the invitee.

$limit

(Optional) Max number of results to return. Default: false (no limit).

Default value: false

$page

(Optional) Page offset of results to return. Default: false (no limit).

Default value: false

$exclude

(Optional) Array or comma-separated list of group IDs to exclude from results.

Default value: false

Return

(array)

  • 'groups'
    (array) Array of groups returned by paginated query.
  • 'total'
    (int) Count of groups matching query.

Source

File: bp-groups/classes/class-bp-groups-member.php

	public static function get_invites( $user_id, $limit = false, $page = false, $exclude = false ) {
		global $wpdb;

		$pag_sql = ( !empty( $limit ) && !empty( $page ) ) ? $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) ) : '';

		if ( !empty( $exclude ) ) {
			$exclude     = implode( ',', wp_parse_id_list( $exclude ) );
			$exclude_sql = " AND g.id NOT IN ({$exclude})";
		} else {
			$exclude_sql = '';
		}

		$bp = buddypress();

		$paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d {$exclude_sql} ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) );

		return array( 'groups' => $paged_groups, 'total' => self::get_invite_count_for_user( $user_id ) );
	}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.