bbp_update_topic_forum_id( int $topic_id, int $forum_id )

Update the topic’s forum id

Description

Parameters

$topic_id

(Optional) Topic id to update

$forum_id

(Optional) Forum id

Return

(int) Forum id

Source

File: bp-forums/topics/functions.php

2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
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.