bp_activity_at_message_notification( int $activity_id, int $receiver_user_id )
Send email and BP notifications when a user is mentioned in an update.
Description
Parameters
- $activity_id
-
(Required) The ID of the activity update.
- $receiver_user_id
-
(Required) The ID of the user who is receiving the update.
Source
File: bp-activity/bp-activity-functions.php
4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 | function bp_activity_at_message_notification( $activity_id , $receiver_user_id ) { $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id , 'all' ); // Don't leave multiple notifications for the same activity item. foreach ( $notifications as $notification ) { if ( $activity_id == $notification ->item_id ) { return ; } } $activity = new BP_Activity_Activity( $activity_id ); $email_type = 'activity-at-message' ; $group_name = '' ; $message_link = bp_activity_get_permalink( $activity_id ); $poster_name = bp_core_get_user_displayname( $activity ->user_id ); remove_filter( 'bp_get_activity_content_body' , 'convert_smilies' ); remove_filter( 'bp_get_activity_content_body' , 'wpautop' ); remove_filter( 'bp_get_activity_content_body' , 'bp_activity_truncate_entry' , 5 ); /** This filter is documented in bp-activity/bp-activity-template.php */ $content = apply_filters_ref_array( 'bp_get_activity_content_body' , array ( $activity ->content, & $activity ) ); add_filter( 'bp_get_activity_content_body' , 'convert_smilies' ); add_filter( 'bp_get_activity_content_body' , 'wpautop' ); add_filter( 'bp_get_activity_content_body' , 'bp_activity_truncate_entry' , 5 ); // Now email the user with the contents of the message (if they have enabled email notifications). if ( 'no' != bp_get_user_meta( $receiver_user_id , 'notification_activity_new_mention' , true ) ) { if ( bp_is_active( 'groups' ) && bp_is_group() ) { $email_type = 'groups-at-message' ; $group_name = bp_get_current_group_name(); } $unsubscribe_args = array ( 'user_id' => $receiver_user_id , 'notification_type' => $email_type , ); $args = array ( 'tokens' => array ( 'activity' => $activity , 'usermessage' => wp_strip_all_tags( $content ), 'group.name' => $group_name , 'mentioned.url' => $message_link , 'poster.name' => $poster_name , 'receiver-user.id' => $receiver_user_id , 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), ), ); bp_send_email( $email_type , $receiver_user_id , $args ); } /** * Fires after the sending of an @mention email notification. * * @since BuddyPress 1.5.0 * @since BuddyPress 2.5.0 $subject, $message, $content arguments unset and deprecated. * * @param BP_Activity_Activity $activity Activity Item object. * @param string $deprecated Removed in 2.5; now an empty string. * @param string $deprecated Removed in 2.5; now an empty string. * @param string $deprecated Removed in 2.5; now an empty string. * @param int $receiver_user_id The ID of the user who is receiving the update. */ do_action( 'bp_activity_sent_mention_email' , $activity , '' , '' , '' , $receiver_user_id ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.2.0 | 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.