groups_check_has_invite_from_user( int $user_id, int $group_id, string $inviter_id = false, string $type = 'sent' )

Check to see whether a user has already been invited to a group by a particular user.


Description Description

By default, the function checks for invitations that have been sent. Entering ‘all’ as the $type parameter will return unsent invitations as well (useful to make sure AJAX requests are not duplicated).


Parameters Parameters

$user_id

(Required) ID of potential group member.

$group_id

(Required) ID of potential group.

$inviter_id

(Optional) Use 'sent' to check for sent invites, 'all' to check for all. Default: 'sent'.

Default value: false

$type

(Optional) Specify a user ID to limit to only invited from that user. Default: 'false'.

Default value: 'sent'


Top ↑

Return Return

(int|bool) ID of the first found membership if found, otherwise false.


Top ↑

Source Source

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

 function groups_check_has_invite_from_user( $user_id, $group_id, $inviter_id = false, $type = 'sent' ) {
	if ( empty( $user_id ) || empty( $group_id ) ) {
		return false;
	}

	$args = array(
		'user_id'     => $user_id,
		'item_id'     => $group_id,
		'invite_sent' => 'sent',
	);
	if ( $inviter_id ) {
		$args['inviter_id'] = $inviter_id;
	}
	if ( $type === 'draft' || $type === 'all' ) {
		$args['invite_sent'] = $type;
	}

	$invites_class = new BP_Groups_Invitation_Manager();

	return $invites_class->invitation_exists( $args );
}

Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.