bbp_buddypress_add_notification( int $reply_id, int $topic_id, int $forum_id, array $anonymous_data = false, int $author_id, bool $is_edit = false, int $reply_to )
Hooked into the new reply function, this notification action is responsible for notifying topic and hierarchical reply authors of topic replies.
Description
Parameters
- $reply_id
-
(Required)
- $topic_id
-
(Required)
- $forum_id
-
(Required) (not used)
- $anonymous_data
-
(Optional) (not used)
Default value: false
- $author_id
-
(Required)
- $is_edit
-
(Optional) Used to bail if this gets hooked to an edit action
Default value: false
- $reply_to
-
(Required)
Source
File: bp-forums/notifications.php
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | function bbp_buddypress_add_notification( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false, $reply_to = 0 ) { // Bail if somehow this is hooked to an edit action if ( ! empty ( $is_edit ) ) { return ; } // Get autohr information $topic_author_id = bbp_get_topic_author_id( $topic_id ); $secondary_item_id = $author_id ; // Hierarchical replies if ( ! empty ( $reply_to ) ) { $reply_to_item_id = bbp_get_topic_author_id( $reply_to ); } // Get some reply information $args = array ( 'user_id' => $topic_author_id , 'item_id' => $topic_id , 'component_name' => bbp_get_component_name(), 'component_action' => 'bbp_new_reply' , 'date_notified' => get_post( $reply_id )->post_date, ); // Notify the topic author if not the current reply author if ( $author_id !== $topic_author_id ) { $args [ 'secondary_item_id' ] = $secondary_item_id ; bp_notifications_add_notification( $args ); } // Notify the immediate reply author if not the current reply author if ( ! empty ( $reply_to ) && ( $author_id !== $reply_to_item_id ) ) { $args [ 'secondary_item_id' ] = $reply_to_item_id ; bp_notifications_add_notification( $args ); } } |
Changelog
Version | Description |
---|---|
bbPress (r5156) | 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.