bp_group_get_message_status( int|bool $group_id = false )

Get the message status of a group.

Description

This function can be used either in or out of the loop.

Parameters

$group_id

(Optional) The ID of the group whose status you want to check. Default: the displayed group, or the current group in the loop.

Default value: false

Return

(bool|string) Returns false when no group can be found. Otherwise returns the group message status, from among 'mods', and 'admins'.

Source

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

7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
function bp_group_get_message_status( $group_id = false ) {
    global $groups_template;
 
    if ( ! $group_id ) {
        $bp = buddypress();
 
        if ( isset( $bp->groups->current_group->id ) ) {
            // Default to the current group first.
            $group_id = $bp->groups->current_group->id;
        } elseif ( isset( $groups_template->group->id ) ) {
            // Then see if we're in the loop.
            $group_id = $groups_template->group->id;
        } else {
            return false;
        }
    }
 
    $message_status = groups_get_groupmeta( $group_id, 'message_status' );
 
    // Backward compatibility. When 'message_status' is not set, fall back to a default value.
    if ( ! $message_status ) {
        $message_status = apply_filters( 'bp_group_message_status_fallback', 'mods' );
    }
 
    /**
     * Filters the message status of a group.
     *
     * Message status in this case means who from the group can send messages.
     *
     * @since BuddyBoss 1.2.3
     *
     * @param string $message_status Membership level needed to manage messages.
     * @param int    $group_id      ID of the group whose status is being checked.
     */
    return apply_filters( 'bp_group_get_message_status', $message_status, $group_id );
}

Changelog

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