groups_is_user_pending( int $user_id, int $group_id )

Check whether a user has a pending membership request for a group.

Description

Parameters

$user_id

(Required) ID of the user.

$group_id

(Required) ID of the group.

Return

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

Source

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

1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
function groups_is_user_pending( $user_id, $group_id ) {
    $is_pending = false;
 
    $user_groups = bp_get_user_groups( $user_id, array(
        'invite_sent' => false,
        'is_confirmed' => false,
    ) );
 
    if ( isset( $user_groups[ $group_id ] ) ) {
        $is_pending = $user_groups[ $group_id ]->id;
    }
 
    return $is_pending;
}

Changelog

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