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!
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.