bbp_create_initial_content( array $args = array() )
Create a default forum, topic, and reply
Description
Parameters
- $args
-
(Optional) Array of arguments to override default values
Default value: array()
Source
File: bp-forums/core/update.php
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | 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
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.