bp_activity_at_name_send_emails

Sends emails and BP notifications for users @-mentioned in an activity item.

Description

bp_activity_at_name_send_emails( (BP_Activity_Activity) $activity ); 

Parameters (1)

0. $activity (BP_Activity_Activity)
The BP_Activity_Activity object.

Usage

  1. if ( !function_exists( 'bp_activity_at_name_send_emails' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-filters.php'; 
  3.  
  4. // The BP_Activity_Activity object. 
  5. $activity = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_at_name_send_emails($activity); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-filters.php  
  1. function bp_activity_at_name_send_emails( $activity ) { 
  2. // Are mentions disabled? 
  3. if ( ! bp_activity_do_mentions() ) { 
  4. return; 
  5.  
  6. // If our temporary variable doesn't exist, stop now. 
  7. if ( empty(buddypress)->activity->mentioned_users ) ) 
  8. return; 
  9.  
  10. // Grab our temporary variable from bp_activity_at_name_filter_updates(). 
  11. $usernames =buddypress)->activity->mentioned_users; 
  12.  
  13. // Get rid of temporary variable. 
  14. unset(buddypress)->activity->mentioned_users ); 
  15.  
  16. // Send @mentions and setup BP notifications. 
  17. foreach( (array) $usernames as $user_id => $username ) { 
  18.  
  19. /** 
  20. * Filters BuddyPress' ability to send email notifications for @mentions. 
  21. * @since 1.6.0 
  22. * @since 2.5.0 Introduced `$user_id` and `$activity` parameters. 
  23. * @param bool $value Whether or not BuddyPress should send a notification to the mentioned users. 
  24. * @param array $usernames Array of users potentially notified. 
  25. * @param int $user_id ID of the current user being notified. 
  26. * @param BP_Activity_Activity $activity Activity object. 
  27. */ 
  28. if ( apply_filters( 'bp_activity_at_name_do_notifications', true, $usernames, $user_id, $activity ) ) { 
  29. bp_activity_at_message_notification( $activity->id, $user_id ); 
  30.  
  31. // Updates mention count for the user. 
  32. bp_activity_update_mention_count_for_user( $user_id, $activity->id );