BP_Groups_Group::get_invites( int $user_id, int $group_id, int|null $sent = null )

Get IDs of users with outstanding invites to a given group from a specified user.

Description

Parameters

$user_id

(int) (Required) ID of the inviting user.

$group_id

(int) (Required) ID of the group.

$sent

(int|null) (Optional) Query for a specific invite sent status. If 0, this will query for users that haven't had an invite sent to them yet. If 1, this will query for users that have had an invite sent to them. If null, no invite status will queried. Default: null.

Default value: null

Return

(array) IDs of users who have been invited to the group by the user but have not yet accepted.

Source

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

	public static function get_invites( $user_id, $group_id, $sent = null ) {
		global $wpdb;

		$bp  = buddypress();
		$sql = $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id );

		// Query for a specific invite sent status.
		if ( ! is_null( $sent ) ) {
			$sql .= $wpdb->prepare( ' AND invite_sent = %d', $sent );
		}

		return $wpdb->get_col( $sql );
	}

Changelog

Changelog
Version Description
BuddyPress 2.9.0 Added $sent as a parameter. BuddyPress 2.9.0 Added $sent as a parameter.
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.