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

(array) (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_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.