groups_is_user_invited( int $user_id, int $group_id, string $type = 'sent' )

Check whether a user has an outstanding invitation to a group.

Description

Parameters

$user_id

(int) (Required) ID of the user.

$group_id

(int) (Required) ID of the group.

$type

(string) (Optional) If 'sent', results are limited to those invitations that have actually been sent (non-draft). Possible values: 'sent', 'draft', or 'all' Default: 'sent'.

Default value: 'sent'

Return

(int|bool) ID of the membership if the user is invited, otherwise false.

Source

File: bp-groups/bp-groups-functions.php

function groups_is_user_invited( $user_id, $group_id ) {
	$is_invited = false;

	$user_groups = bp_get_user_groups( $user_id, array(
		'invite_sent' => true,
		'is_confirmed' => false,
	) );

	if ( isset( $user_groups[ $group_id ] ) ) {
		$is_invited = $user_groups[ $group_id ]->id;
	}

	return $is_invited;
}

Changelog

Changelog
Version Description
BuddyPress 5.0.0 Added $type parameter. BuddyPress 5.0.0 Added $type parameter.
BuddyPress 2.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.