bbp_update_reply_topic_id( int $reply_id, int $topic_id )
Update the reply with its topic id it is in
Description
Parameters
- $reply_id
-
(int) (Optional) Reply id to update
- $topic_id
-
(int) (Optional) Topic id
Return
(bool) Reply's topic id
Source
File: bp-forums/replies/functions.php
function bbp_update_reply_topic_id( $reply_id = 0, $topic_id = 0 ) { // Validation $reply_id = bbp_get_reply_id( $reply_id ); $topic_id = bbp_get_topic_id( $topic_id ); // If no topic_id was passed, walk up ancestors and look for topic type if ( empty( $topic_id ) ) { // Get ancestors $ancestors = (array) get_post_ancestors( $reply_id ); // Loop through ancestors if ( !empty( $ancestors ) ) { foreach ( $ancestors as $ancestor ) { // Get first parent that is a forum if ( get_post_field( 'post_type', $ancestor ) === bbp_get_topic_post_type() ) { $topic_id = $ancestor; // Found a forum, so exit the loop and continue continue; } } } } // Update the topic ID bbp_update_topic_id( $reply_id, $topic_id ); return apply_filters( 'bbp_update_reply_topic_id', (int) $topic_id, $reply_id ); }
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.