bbp_update_topic_forum_id( int $topic_id, int $forum_id )

Update the topic’s forum id

Description

Parameters

$topic_id

(int) (Optional) Topic id to update

$forum_id

(int) (Optional) Forum id

Return

(int) Forum id

Source

File: bp-forums/topics/functions.php

function bbp_update_topic_forum_id( $topic_id = 0, $forum_id = 0 ) {

	// If it's a reply, then get the parent (topic id)
	if ( bbp_is_reply( $topic_id ) ) {
		$topic_id = bbp_get_reply_topic_id( $topic_id );
	} else {
		$topic_id = bbp_get_topic_id( $topic_id );
	}

	if ( empty( $forum_id ) ) {
		$forum_id = get_post_field( 'post_parent', $topic_id );
	}

	update_post_meta( $topic_id, '_bbp_forum_id', (int) $forum_id );

	return apply_filters( 'bbp_update_topic_forum_id', (int) $forum_id, $topic_id );
}

Changelog

Changelog
Version Description
bbPress (r2855) 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.