bbp_create_initial_content( array $args = array() )

Create a default forum, topic, and reply

Description

Parameters

$args

(array) (Optional) Array of arguments to override default values

Default value: array()

Source

File: bp-forums/core/update.php

function bbp_create_initial_content( $args = array() ) {

	// Parse arguments against default values
	$r = bbp_parse_args( $args, array(
		'forum_parent'  => 0,
		'forum_status'  => 'publish',
		'forum_title'   => __( 'General',                                  'buddyboss' ),
		'forum_content' => __( 'General chit-chat',                        'buddyboss' ),
		'topic_title'   => __( 'Hello World!',                             'buddyboss' ),
		'topic_content' => __( 'I am the first discussion in your new forums.', 'buddyboss' ),
		'reply_title'   => __( 'Re: Hello World!',                         'buddyboss' ),
		'reply_content' => __( 'Oh, and this is what a reply looks like.', 'buddyboss' ),
	), 'create_initial_content' );

	// Create the initial forum
	$forum_id = bbp_insert_forum( array(
		'post_parent'  => $r['forum_parent'],
		'post_status'  => $r['forum_status'],
		'post_title'   => $r['forum_title'],
		'post_content' => $r['forum_content']
	) );

	// Create the initial topic
	$topic_id = bbp_insert_topic(
		array(
			'post_parent'  => $forum_id,
			'post_title'   => $r['topic_title'],
			'post_content' => $r['topic_content']
		),
		array( 'forum_id'  => $forum_id )
	);

	// Create the initial reply
	$reply_id = bbp_insert_reply(
		array(
			'post_parent'  => $topic_id,
			'post_title'   => $r['reply_title'],
			'post_content' => $r['reply_content']
		),
		array(
			'forum_id'     => $forum_id,
			'topic_id'     => $topic_id
		)
	);

	return array(
		'forum_id' => $forum_id,
		'topic_id' => $topic_id,
		'reply_id' => $reply_id
	);
}

Changelog

Changelog
Version Description
bbPress (r3767) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.