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
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | 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.