bbp_create_initial_content

Create a default forum, topic, and reply.

Description

bbp_create_initial_content( (array) $args = array() ); 

Parameters (1)

0. $args — Optional. (array) => array()
Array of arguments to override default values

Usage

  1. if ( !function_exists( 'bbp_create_initial_content' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/core/update.php'; 
  3.  
  4. // Array of arguments to override default values 
  5. $args = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_create_initial_content($args); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/core/update.php  
  1. function bbp_create_initial_content( $args = array() ) { 
  2.  
  3. // Parse arguments against default values 
  4. $r = bbp_parse_args( $args, array( 
  5. 'forum_parent' => 0,  
  6. 'forum_status' => 'publish',  
  7. 'forum_title' => __( 'General', bbpress ),  
  8. 'forum_content' => __( 'General chit-chat', bbpress ),  
  9. 'topic_title' => __( 'Hello World!', bbpress ),  
  10. 'topic_content' => __( 'I am the first topic in your new forums.', bbpress ),  
  11. 'reply_title' => __( 'Re: Hello World!', bbpress ),  
  12. 'reply_content' => __( 'Oh, and this is what a reply looks like.', bbpress ),  
  13. ), 'create_initial_content' ); 
  14.  
  15. // Create the initial forum 
  16. $forum_id = bbp_insert_forum( array( 
  17. 'post_parent' => $r['forum_parent'],  
  18. 'post_status' => $r['forum_status'],  
  19. 'post_title' => $r['forum_title'],  
  20. 'post_content' => $r['forum_content'] 
  21. ) ); 
  22.  
  23. // Create the initial topic 
  24. $topic_id = bbp_insert_topic
  25. array( 
  26. 'post_parent' => $forum_id,  
  27. 'post_title' => $r['topic_title'],  
  28. 'post_content' => $r['topic_content'] 
  29. ),  
  30. array( 'forum_id' => $forum_id ) 
  31. ); 
  32.  
  33. // Create the initial reply 
  34. $reply_id = bbp_insert_reply
  35. array( 
  36. 'post_parent' => $topic_id,  
  37. 'post_title' => $r['reply_title'],  
  38. 'post_content' => $r['reply_content'] 
  39. ),  
  40. array( 
  41. 'forum_id' => $forum_id,  
  42. 'topic_id' => $topic_id 
  43. ); 
  44.  
  45. return array( 
  46. 'forum_id' => $forum_id,  
  47. 'topic_id' => $topic_id,  
  48. 'reply_id' => $reply_id 
  49. );