groups_is_user_allowed_posting( int $user_id, int $group_id )

Check whether a user is allowed to post in a given group.

Description

Parameters

$user_id

(Required) ID of the user.

$group_id

(Required) ID of the group.

Return

(bool) true if the user is allowed, otherwise false.

Source

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

1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
function groups_is_user_allowed_posting( $user_id, $group_id ) {
    $is_allowed = false;
 
    if ( ! is_user_logged_in() ) {
        return false;
    }
 
    // Site admins always have access.
    if ( bp_current_user_can( 'bp_moderate' ) ) {
        return true;
    }
 
    if ( ! groups_is_user_member( $user_id, $group_id ) ) {
        return false;
    }
 
    $status    = bp_group_get_activity_feed_status( $group_id );
    $is_admin  = groups_is_user_admin( $user_id, $group_id );
    $is_mod    = groups_is_user_mod( $user_id, $group_id );
 
    if ( 'members' == $status ) {
        $is_allowed = true;
    } else if ( 'mods' == $status && ( $is_mod || $is_admin ) ) {
        $is_allowed = true;
    } else if ( 'admins' == $status && $is_admin ) {
        $is_allowed = true;
    }
 
    return $is_allowed;
}

Changelog

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