bp_dd_create_forums_topics( $topic_data, $forum_id, array $users = array() )
Function to create topic inside forums
Description
Parameters
- $topic_data
-
(Required)
- $forum_id
-
(Required)
- $users
-
(Optional)
Default value: array()
Return
(bool|int|WP_Error)
Source
File: bp-core/bp-core-tools-default-data.php
function bp_dd_create_forums_topics( $topic_data, $forum_id, $users = array() ) { $topic_id = false; if ( empty( $users ) ) { $users = bp_dd_get_random_users_ids( 0 ); } $creator_id = is_object( $users[ array_rand( $users ) ] ) ? $users[ array_rand( $users ) ]->ID : $users[ array_rand( $users ) ]; // Create the initial topic $topic_id = bbp_insert_topic( array( 'post_parent' => $forum_id, 'post_title' => $topic_data['name'], 'post_content' => $topic_data['description'], 'post_status' => $topic_data['status'], 'post_author' => $creator_id, ), array( 'forum_id' => $forum_id ) ); return $topic_id; }
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.