Skip to:
Content
Pages
Categories
Search
Top
Bottom

Integration with PHP for New Topic (bbp 2.1)

  • I just installed 2.1.bleeding to try out bbPress on my site. Totally automatic and smooth as could be. For the record, I’m using the Simple X theme on my blog. Layout needs a little tweaking, but it all worked immediately.

    Most of my site is PHP with the blog secondary. My goal is for the user on a custom PHP page to create a ‘item’ on the base site, and at the same time begin a discussion topic about the ‘item’ on bbPress. They would complete a form with various data that includes a title and comment box. I want to take what they enter and handle part of it on my current site and then create a related new forum topic using the title and comment.

    I suspect this can be done by calling some ‘create topic’ function, but being a novice at this I have no clue how. For the record, my url structure looks like ‘xyz.com/blog/forums’.

    Is this possible? If so, how?

    Thanks for any help,

    Hugh

Viewing 1 replies (of 1 total)
  • Hate to answer my own question, but in case anyone wants to try this here is some sample code to start with -

    <html>
    <body>
    This is it.
    <?php
    // include WordPress
    define('WP_USE_THEMES', false);
    require('./blog/wp-load.php');

    // Handle INSERT if data is Posted
    if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "bbp-new-topic") {
    $new_topic = array(
    'post_parent' => $_POST['bbp_forum_id'], // forum ID
    'post_content' => $_POST['bbp_topic_content'],
    'post_title' => $_POST['bbp_topic_title']
    );
    $topic_meta = array(
    'forum_id' => $new_topic['post_parent']
    );

    $topic_id = bbp_insert_topic($new_topic, $topic_meta);
    echo('<br>Topic ID = '.$topic_id . '<br>');
    } // end INSERT

    // Use Shortcode to show New Topic Form.
    // Could also create your own form.
    echo do_shortcode('[bbp-topic-form]');
    ?>
    Thats it.
    </body></html>

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.