groups_is_user_banned( int $user_id, int $group_id )

Check whether a user is banned from a given 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 banned, otherwise false.

Source

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

1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
function groups_is_user_banned( $user_id, $group_id ) {
    $is_banned = false;
 
    $user_groups = bp_get_user_groups( $user_id, array(
        'is_confirmed' => null,
        'is_banned' => true,
    ) );
 
    if ( isset( $user_groups[ $group_id ] ) ) {
        $is_banned = $user_groups[ $group_id ]->id;
    }
 
    return $is_banned;
}

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.