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
-
(Optional) Reply id to update
- $topic_id
-
(Optional) Topic id
Return
(bool) Reply's topic id
Source
File: bp-forums/replies/functions.php
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 | 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.