bp_dd_import_forums_topics_replies( $topics = false )

Import replies in to forums.

Description

Parameters

$forums

(Required) We can import random groups or work with a predefined list.

Return

(array)

Source

File: bp-core/bp-core-tools-default-data.php

1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
function bp_dd_import_forums_topics_replies( $topics = false ) {
    $replies   = array();
    $reply_ids = bp_get_option( 'bp_dd_imported_reply_ids', array() );
 
    if ( ! bp_is_active( 'forums' ) ) {
        return $reply_ids;
    }
 
    if ( ! $topics ) {
        $topics = bp_dd_get_random_topics_ids( 0 );
    }
 
    $users = bp_dd_get_random_users_ids( 0 );
 
    require( BP_DEFAULT_DATA_DIR . 'data/forums_replies.php' );
 
    foreach ( $topics as $topic_id ) {
 
        $reply = (array) array_rand( $replies, absint( rand( 1, 7 ) ) );
 
        foreach ( $reply as $reply_key ) {
            $reply_data = $replies[ $reply_key ];
 
            $reply_id = bp_dd_create_forums_topics_replies( $reply_data, $topic_id, $users );
 
            if ( ! empty( $reply_id ) ) {
                $reply_ids[] = $reply_id;
            }
        }
    }
 
    if ( ! empty( $reply_ids ) ) {
        /** @noinspection PhpParamsInspection */
        bp_update_option( 'bp_dd_imported_reply_ids', array_unique( $reply_ids ) );
    }
 
    return $reply_ids;
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 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.