bbp_update_reply_forum_id( int $reply_id, int $forum_id )
Update the reply with its forum id it is in
Description
Parameters
- $reply_id
-
(Optional) Reply id to update
- $forum_id
-
(Optional) Forum id
Return
(bool) Reply's forum id
Source
File: bp-forums/replies/functions.php
function bbp_update_reply_forum_id( $reply_id = 0, $forum_id = 0 ) { // Validation $reply_id = bbp_get_reply_id( $reply_id ); $forum_id = bbp_get_forum_id( $forum_id ); // If no forum_id was passed, walk up ancestors and look for forum type if ( empty( $forum_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_forum_post_type() ) { $forum_id = $ancestor; // Found a forum, so exit the loop and continue continue; } } } } // Update the forum ID bbp_update_forum_id( $reply_id, $forum_id ); return apply_filters( 'bbp_update_reply_forum_id', (int) $forum_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.