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

Is the forum public?

Description

Parameters

$forum_id

(int) (Optional) Forum id

$check_ancestors

(bool) (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

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.