BBP_Shortcodes::display_forum( array $attr, string $content = '' )

Display the contents of a specific forum ID in an output buffer and return to ensure that post/page contents are displayed first.


Description Description


Parameters Parameters

$attr

(Required)

$content

(Optional)

Default value: ''


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/common/shortcodes.php

	public function display_forum( $attr, $content = '' ) {

		// Sanity check required info
		if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) {
			return $content;
		}

		// Set passed attribute to $forum_id for clarity
		$forum_id = bbpress()->current_forum_id = $attr['id'];

		// Bail if ID passed is not a forum
		if ( ! bbp_is_forum( $forum_id ) ) {
			return $content;
		}

		// Start output buffer
		$this->start( 'bbp_single_forum' );

		// Check forum caps
		if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) {
			bbp_get_template_part( 'content',  'single-forum' );

		// Forum is private and user does not have caps
		} elseif ( bbp_is_forum_private( $forum_id, false ) ) {
			bbp_get_template_part( 'feedback', 'no-access'    );
		}

		// Return contents of output buffer
		return $this->end();
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.