Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating a topic with bbp_insert_topic shows up on two forums

  • @alamsyed

    Participant

    This is my scenario,

    I create a private Forum of type category , then I create two public forums to type forum which are the children of that category forum. I get a nice category level organization, when I click on the url,

    Home/ Forums/ Private: DummyCategory.

    But when I click on one of the forums :: Home/ Forums/ Private: DummyCategory/ DummyForum1

    all the posts that do not belong to that forum shows up. It means if I post in DummyForum2 or 1 or any forum, when I click Home/ Forums/ Private: DummyCategory/ DummyForum1 , all the posts show up.

    It can’t be by design ? Is this a bug ? Most likely some settings need to be changed in the bbpress I suppose , any idea ?

    Just for additional details I am using code to add into the forum. I can get the parent child relations between the forums displayed properly, the insertion of the topic goes to the right parent forum. But then that bug shows up.

    if (!function_exists('bbp_insert_topic')) {
                require_once '/includes/topics/functions.php';
            }
    
            echo "All fine here ??? Did it reached ";
            $forum_ID = $selectmyID;
            $terms = array(bbp_get_topic_tag_tax_id() => $key_pieces);
            // The topic data.
            $topic_data = array(
            'post_parent'       => $forum_ID, // forum ID of Projects  hard coded
            'post_status'       => bbp_get_public_status_id(),   // Subscribed users can see this
            'post_content'      => $my_content,
            'post_title'        => $slug,
            'comment_status'    => 'open',
            'menu_order'        => 0,
            'tax_input'         => $terms  
            );
    
            // The topic meta.
            $topic_meta = array(
            'forum_id'    => $topic_data['post_parent'],
            'reply_count' => 0
            );
    
            // NOTICE! Understand what this does before running.
            $post_id = bbp_insert_topic($topic_data, $topic_meta);
            bbp_stick_topic($post_id , true);                         // Making it super sticky !
    
            echo "The post id returned is " . $post_id;
            echo "Sucessfully inserted the post" . $slug . " programmatically !!!!";
Viewing 9 replies - 1 through 9 (of 9 total)
  • @robin-w

    Moderator

    sorry but I am not sure what exactly the issue is.

    It would seem that

    Without your code you have problem a

    and with your code you have problem b

    is that it, AND IF SO can you state your problem without the code you added?

    @alamsyed

    Participant

    Ok the issue is simple. Inserting a topic using the code I have shown I can get the correct child-parent relationship into a forum. However the same topic shows up in a different forum other than the parent and that feels like a bug. Without the code, there is no problem at all if the topic is created from the front end.

    @robin-w

    Moderator

    no sorry I still don’t know what exactly your issue is.

    WITHOUT THE CODE – what is the problem?

    @alamsyed

    Participant

    WITHOUT THE CODE – what is the problem ? None !
    WITH THE CODE – what is the problem ? Topic shows up in outside parent forum !

    @robin-w

    Moderator

    I answer q’s across many forums, and don’t have the time to work out what it is trying to do so what’s the purpose of the code then?

    @alamsyed

    Participant

    To insert a topic in a parent forum with given id. But after successful insertion the topic shows up in other forums and doesnt remain inside the parent forum. The code is a standard way to insert a topic in bbpress programmatically.

    I am just trying to learn this so I can build my website. Thanks for your attention.

    1. http://hookr.io/functions/bbp_insert_topic/
    2. https://github.com/rmccue/bbPress/blob/master/bbp-includes/bbp-topic-functions.php etc.

    @robin-w

    Moderator

    ok, now that you have explained what it is, I understand and can help !

    In the code is

     // NOTICE! Understand what this does before running.
            $post_id = bbp_insert_topic($topic_data, $topic_meta);
            bbp_stick_topic($post_id , true);                         // Making it super sticky !

    If you had done this – ie Understand what this does before running.
    you would have known the answer –

    sticky sticks a topic to the top of the forum it belongs in.

    super-sticky sticks a topic to the top of all forums

    @alamsyed

    Participant

    Aww. Sorry for asking silly questions. I misunderstood what super sticky means, I thought it makes the topic persistent and fancy in looks πŸ™‚ In my case I only need functionality of sticky and not super sticky. I am still learning all this, so I hope I didn’t annoy you. I am just trying to build my website with no prior experience to web development whatsoever just traditional C++. Thanks again this is resolved I checked it.

    @robin-w

    Moderator

    no problem – I’m glad you’re fixed !!

    We all learn all the time πŸ™‚

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar