groups_check_for_membership_request( int $user_id, int $group_id )

Check whether a user has an outstanding membership request for a given group.

Description

Parameters

$user_id

(int) (Required) ID of the user.

$group_id

(int) (Required) ID of the group.

Return

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

Source

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

function groups_check_for_membership_request( $user_id, $group_id ) {
	$request = false;

	$user_groups = bp_get_user_groups( $user_id, array(
		'is_confirmed' => false,
		'is_banned'    => false,
		'is_admin'     => null,
		'is_mod'       => null
	) );

	if ( isset( $user_groups[ $group_id ] ) && 0 === $user_groups[ $group_id ]->inviter_id ) {
		$request = $user_groups[ $group_id ]->id;
	}

	return $request;
}

Changelog

Changelog
Version Description
BuddyPress 1.0.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.