Skip to:

Method to bulk post a single topic to multiple forums at once?

  • omnialive


    I have a site that silos students into forums by course and the into 4 main groups which are broken down into two smaller groups, A and B.

    This means there is a forum for the course, then 4 sub-forums under that and within each of these there are two sub-sub-forums (using this just for visualization help).

    What I am wanting to do is bulk create an identical topic into all of the 8 smaller groups (A’s and B’s). They have a weekly assignment that they will need to post a reply to this topic as part of the course flow.

    I’ve done quite a few Google searches and haven’t found anything as of yet. I’m looking to just develop something on my own “quick and dirty”…but would like to avoid that!

Viewing 3 replies - 1 through 3 (of 3 total)

  • Robin W


    you don’t say how technical you are, but if you can do basic coding, the guts of creating a topic is

    $topic_data = array(
    		'post_author'    => $topic_author,
    		'post_title'     => $topic_title,
    		'post_content'   => $topic_content,
    		'post_status'    => $topic_status,
    		'post_parent'    => $forum_id,
    		'post_type'      => bbp_get_topic_post_type(),
    		'tax_input'      => $terms,
    		'comment_status' => 'closed'
    	) ;
    	// Insert topic
    	$topic_id = wp_insert_post( $topic_data, true );
    //this updates counts subscriptions etc,
    do_action( 'bbp_new_topic', $topic_id, $forum_id, $anonymous_data, $topic_author );

    so you could wrap the above in a function and create a 2nd function that creates the above variables, and then loops round the 8 forum_id’s to create 8 topics



    Hey Robin,

    Thanks a tremendous amount for that! I’m actually very technical (can program [at least minimally] in several languages including PHP). I’m in Healthcare IT as my day job.

    For what I need, this will work grand! If I have any HTML content in the $topic_content…is there an escape or normalization function I would need to run that through first?

    I haven’t really dove into WP development at all…so in that regard I’m a complete n00b.

    Thanks and gratitude again!

    Robin W


    that’s great.

    You might want to take a look at bbp_new_topic_handler which I took this code from and gives you checks for all the parameters.

    which is in

    bbpress 2.6.6\includes\topics\functions.php line 96 onwards

    to see what checks bbpress does to the data before processing. This function is used by the new topic form.

    the content is hooked to 4 functions, 3 of which are removed for capable uses on line 140 etc.

    presuming that you are creating the content so will not be trying to break or do naugthy things, then you can probaby ignore these.

    bbpress does one more it calls the function bbp_code_trick from the filter on line 173

    which is this in bbpress 2.6.6\includes\common\formatting.php

    function bbp_code_trick( $content = '' ) {
    	$content = str_replace( array( "\r\n", "\r" ), "\n", $content );
    	$content = preg_replace_callback( "|(<code>)(.*?)</code>|",      'bbp_encode_callback', $content );
    	$content = preg_replace_callback( "!(^|\n)<code>(.*?)</code>!s", 'bbp_encode_callback', $content );
    	return $content;

    If you’re trying things, then I’d suggest you create some draft items in bbpress and then see what content is in the database to see what you would need to save there.

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