bbp_buddypress_add_topic_notification( int $topic_id, int $forum_id )
Hooked into the new topic function, this notification action is responsible for notifying topic.
Description
Parameters
- $topic_id
-
(Required)
- $forum_id
-
(Required)
Source
File: bp-forums/notifications.php
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | function bbp_buddypress_add_topic_notification( $topic_id , $forum_id ) { // If our temporary variable doesn't exist, stop now. if ( empty ( buddypress()->forums->mentioned_users ) ) { return ; } // Get some topic information $args = array ( 'item_id' => $topic_id , 'secondary_item_id' => get_current_user_id(), 'component_name' => bbp_get_component_name(), 'component_action' => 'bbp_new_at_mention' , ); // Grab our temporary variable from bbp_convert_mentions(). $usernames = buddypress()->forums->mentioned_users; // Get rid of temporary variable. unset( buddypress()->forums->mentioned_users ); // We have mentions! if ( ! empty ( $usernames ) ) { // Send @mentions and setup BP notifications. foreach ( ( array ) $usernames as $user_id => $username ) { // Current user is the same user then do not send notification. if ( $user_id === get_current_user_id() ) { continue ; } $args [ 'user_id' ] = $user_id ; // If forum is not accesible to user, do not send notification. $can_access = bbp_user_can_view_forum( array ( 'user_id' => $user_id , 'forum_id' => $forum_id , 'check_ancestors' => true ) ); /** * Filters bbPress' ability to send notifications for @mentions. * * @param bool $value Whether or not BuddyPress should send a notification to the mentioned users. * @param array $usernames Array of users potentially notified. * @param int $user_id ID of the current user being notified. * @param int $forum_id ID of forum. * * @since BuddyBoss 1.2.9 * */ if ( ! apply_filters( 'bbp_forums_at_name_do_notifications' , $can_access , $usernames , $user_id , $forum_id ) ) { continue ; } bp_notifications_add_notification( $args ); } } } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.2.8 | 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.