bbp_register_view( string $view, string $title, mixed $query_args = '', bool $feed = true, string $capability = '' )

Register a bbPress view


Description Description


Parameters Parameters

$view

(Required) View name

$title

(Required) View title

$query_args

(Optional) bbp_has_topics() arguments.

Default value: ''

$feed

(Optional) Have a feed for the view? Defaults to true.

Default value: true

$capability

(Optional) Capability that the current user must have

Default value: ''


Top ↑

Return Return

(array) The just registered (but processed) view


Top ↑

Source Source

File: includes/core/functions.php

function bbp_register_view( $view, $title, $query_args = '', $feed = true, $capability = '' ) {

	// Bail if user does not have capability
	if ( ! empty( $capability ) && ! current_user_can( $capability ) ) {
		return false;
	}

	$bbp   = bbpress();
	$view  = sanitize_title( $view );
	$title = esc_html( $title );

	if ( empty( $view ) || empty( $title ) ) {
		return false;
	}

	$query_args = bbp_parse_args( $query_args, '', 'register_view' );

	// Set show_stickies to false if it wasn't supplied
	if ( ! isset( $query_args['show_stickies'] ) ) {
		$query_args['show_stickies'] = false;
	}

	$bbp->views[ $view ] = array(
		'title'  => $title,
		'query'  => $query_args,
		'feed'   => $feed
	);

	return $bbp->views[ $view ];
}

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.