bbp_is_forum_public( int $forum_id, bool $check_ancestors = true )

Is the forum public?

Description

Parameters

$forum_id

(Optional) Forum id

$check_ancestors

(Optional) Check if the ancestors are public (only if they're a category)

Default value: true

Return

(bool) True if closed, false if not

Source

File: bp-forums/forums/template.php

1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
function bbp_is_forum_public( $forum_id = 0, $check_ancestors = true ) {
 
    $forum_id   = bbp_get_forum_id( $forum_id );
    $visibility = bbp_get_forum_visibility( $forum_id );
 
    // If post status is public, return true
    $retval = ( bbp_get_public_status_id() === $visibility );
 
    // Check ancestors and inherit their privacy setting for display
    if ( !empty( $check_ancestors ) ) {
        $ancestors = bbp_get_forum_ancestors( $forum_id );
 
        foreach ( (array) $ancestors as $ancestor ) {
            if ( bbp_is_forum( $ancestor ) && bbp_is_forum_public( $ancestor, false ) ) {
                $retval = true;
            }
        }
    }
 
    return (bool) apply_filters( 'bbp_is_forum_public', (bool) $retval, $forum_id, $check_ancestors );
}

Changelog

Changelog
Version Description
bbPress (r2997) 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.