BBP_Shortcodes::display_topic_form( array $attr = array(), string $content = '' )
Display the topic form in an output buffer and return to ensure post/page contents are displayed first.
Description
Supports ‘forum_id’ attribute to display the topic form for a particular forum. This currently has styling issues from not being wrapped in
which will need to be sorted out later.
Parameters
- $attr
-
(Optional)
Default value: array()
- $content
-
(Optional)
Default value: ''
Return
(string)
Source
File: bp-forums/common/shortcodes.php
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | public function display_topic_form( $attr = array (), $content = '' ) { // Sanity check supplied info if ( ! empty ( $content ) || ( ! empty ( $attr [ 'forum_id' ] ) && ( ! is_numeric ( $attr [ 'forum_id' ] ) || !bbp_is_forum( $attr [ 'forum_id' ] ) ) ) ) return $content ; // Unset globals $this ->unset_globals(); // If forum id is set, use the 'bbp_single_forum' query name if ( ! empty ( $attr [ 'forum_id' ] ) ) { // Set the global current_forum_id for future requests bbpress()->current_forum_id = $forum_id = bbp_get_forum_id( $attr [ 'forum_id' ] ); // Start output buffer $this ->start( 'bbp_single_forum' ); // No forum id was passed } else { // Set the $forum_id variable to satisfy checks below $forum_id = 0; // Start output buffer $this ->start( 'bbp_topic_form' ); } // If the forum id is set, check forum caps else display normal topic form if ( empty ( $forum_id ) || bbp_user_can_view_forum( array ( 'forum_id' => $forum_id ) ) ) { bbp_get_template_part( 'form' , 'topic' ); // 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 (); } |
Changelog
Version | Description |
---|---|
bbPress (r3031) | 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.