Skip to:
Content

bbPress.org

Changeset 6329


Ignore:
Timestamp:
02/26/2017 11:06:17 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Core: Allow custom post authors for initial content (forum/topic/reply).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/update.php

    r6325 r6329  
    183183function bbp_create_initial_content( $args = array() ) {
    184184
     185    // Current user ID
     186    $user_id = bbp_get_current_user_id();
     187
    185188    // Parse arguments against default values
    186189    $r = bbp_parse_args( $args, array(
     190        'forum_author'  => $user_id,
    187191        'forum_parent'  => 0,
    188192        'forum_status'  => 'publish',
    189         'forum_title'   => __( 'General',                                  'bbpress' ),
    190         'forum_content' => __( 'General chit-chat',                        'bbpress' ),
     193        'forum_title'   => __( 'General',           'bbpress' ),
     194        'forum_content' => __( 'General chit-chat', 'bbpress' ),
     195
     196        'topic_author'  => $user_id,
    191197        'topic_title'   => __( 'Hello World!',                             'bbpress' ),
    192198        'topic_content' => __( 'I am the first topic in your new forums.', 'bbpress' ),
     199
     200        'reply_author'  => $user_id,
    193201        'reply_content' => __( 'Oh, and this is what a reply looks like.', 'bbpress' ),
    194202    ), 'create_initial_content' );
     
    196204    // Use the same time for each post
    197205    $current_time = time();
    198     $forum_time = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 80 );
    199     $topic_time = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 60 );
    200     $reply_time = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 40 );
     206    $forum_time   = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 80 );
     207    $topic_time   = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 60 );
     208    $reply_time   = date( 'Y-m-d H:i:s', $current_time - 60 * 60 * 40 );
    201209
    202210    // Create the initial forum
    203211    $forum_id = bbp_insert_forum( array(
     212        'post_author'  => $r['forum_author'],
    204213        'post_parent'  => $r['forum_parent'],
    205214        'post_status'  => $r['forum_status'],
     
    212221    $topic_id = bbp_insert_topic(
    213222        array(
     223            'post_author'  => $r['topic_author'],
    214224            'post_parent'  => $forum_id,
    215225            'post_title'   => $r['topic_title'],
    216226            'post_content' => $r['topic_content'],
    217             'post_date'    => $topic_time
     227            'post_date'    => $topic_time,
    218228        ),
    219229        array(
     
    225235    $reply_id = bbp_insert_reply(
    226236        array(
     237            'post_author'  => $r['reply_author'],
    227238            'post_parent'  => $topic_id,
    228239            'post_content' => $r['reply_content'],
Note: See TracChangeset for help on using the changeset viewer.