Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Integration with PHP for New Topic (bbp 2.1)

@piccart

Participant

I’ve just made a button on the topic listing page, which send the variable using a GET url:

<a href="<?php bloginfo( 'url' ); ?>/new-topic/?related_forum_id=<?php bbp_forum_id(); ?>" >New Topic</a>

then in the template to display the new topic form, you add this:

<?php // get the var from the new-topic button
$related_forum_id = $_GET['related_forum_id'];
// display a warning if there is no info about the id
if ($related_forum_id=="") {
	echo "WARNING! Something is wrong here! there is no info about the Related Forum where to append this Topic.<br/>Do not submit the new topic. Please go back and try again.";
}
// create a string with the shortcode
$form_shortcode = '[bbp-topic-form forum_id="'.$related_forum_id.'"]';
// execute the shortcode to display the form
echo do_shortcode($form_shortcode); ?>
Skip to toolbar