bp_dd_create_forums_topics_replies( $reply_data,  $topic_id, array $users = array() )

Return Reply ID

Description

Parameters

$reply_data

(Required)

$topic_id

(Required)

$users

(Optional)

Default value: array()

Return

(bool|int|WP_Error)

Source

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

1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
function bp_dd_create_forums_topics_replies( $reply_data, $topic_id, $users = array() ) {
    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 ) ];
    $forum_id   = get_post_meta( $topic_id, '_bbp_forum_id', true );
 
    $reply_id = bbp_insert_reply(
        array(
            'post_parent'  => $topic_id,
            'post_title'   => '',
            'post_content' => $reply_data,
            'post_author'  => $creator_id,
        ),
        array(
            'topic_id' => $topic_id,
            'forum_id' => $forum_id
        )
    );
 
    if ( ! empty( $reply_id ) ) {
        update_post_meta( $reply_id, '_bbp_topic_id', $topic_id );
    }
 
    return $reply_id;
}

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.