bp_dd_import_forums_topics( bool $forums = false )
Import topics in to forums.
Description
Parameters
- $forums
-
(Optional) We can import random groups or work with a predefined list.
Default value: false
Return
(array)
Source
File: bp-core/bp-core-tools-default-data.php
function bp_dd_import_forums_topics( $forums = false ) { $topics = array(); $topics_ids = bp_get_option( 'bp_dd_imported_topic_ids', array() ); if ( ! bp_is_active( 'forums' ) ) { return $topics_ids; } if ( empty( $forums ) ) { $forums = bp_dd_get_random_forums_ids( 0 ); } $users = bp_dd_get_random_users_ids( 0 ); require( BP_DEFAULT_DATA_DIR . 'data/forums_topics.php' ); foreach ( $forums as $forum_id ) { $topic = (array) array_rand( $topics, absint( rand( 2, count( $topics ) ) ) ); foreach ( $topic as $topic_key ) { $topic_data = $topics[ $topic_key ]; // Create the initial topic $topic_id = bp_dd_create_forums_topics( $topic_data, $forum_id, $users ); if ( ! empty( $topic_id ) ) { $topics_ids[] = $topic_id; } } } if ( ! empty( $topics_ids ) ) { /** @noinspection PhpParamsInspection */ bp_update_option( 'bp_dd_imported_topic_ids', array_unique( $topics_ids ) ); } return $topics_ids; }
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.