[buddypress-trac] [BuddyPress Trac] #5395: Notify everyone that comments on an activity update of new comments

buddypress-trac noreply at wordpress.org
Wed Feb 12 22:50:03 UTC 2014

#5395: Notify everyone that comments on an activity update of new comments
 Reporter:  terraling    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Core         |    Version:
 Severity:  normal       |   Keywords:
 On my site I don't have nested BuddyPress comments in the activity stream
 and it threw up an issue that I've resolved and thought I'd share here in
 case it is useful.

 Jack posts a status update.
 Jill comments on Jack's update (Jack gets an email notice)
 John chimes in and comments on Jack's update (Jack gets an email notice,
 Jill doesn't)
 Jack comments to both of them with a reply to his own update (no-one gets
 an email notice)

 That's how people are familiar with commenting on status updates from FB.

 If Jack responds individually to each with the nested comments, John and
 Jill are unaware of the other's ongoing conversations with Jack, although
 they might expect to be kept in the loop.

 I'm not doing anything fancy with notifications, but have reworked
 bp_activity_new_comment_notification so that everyone in a conversation
 thread (apart from the person posting the comment) gets an email notice.

 It now looks something like this:

 function my_activity_new_comment_notification( $comment_id, $params ) {
         global $wpdb;
         // Set some default parameters
         $activity_id = 0;
         $parent_id   = 0;

         extract( $params );

         $conversation_ids = $wpdb->get_results( "
                 SELECT DISTINCT user_id
                 FROM wp_bp_activity
                 WHERE item_id = " . $activity_id . "
                 AND user_id != " . $user_id     ); // list of user_ids of
 anyone involved in the conversation except current commenter

         $poster_name   = bp_core_get_user_displayname( $user_id );
         $thread_link   = bp_activity_get_permalink( $activity_id );
         $poster_name = stripslashes( $poster_name );
         $content = bp_activity_filter_kses( stripslashes($content) );

         if ( !empty($conversation_ids) ) { //to rule out someone talking
 to themselves
                 foreach ($conversation_ids as $conversation_id) {
                         // Set up and send the message
                         $ud      = bp_core_get_core_userdata(
 $conversation_id->user_id );
                         $to      = $ud->user_email;
                         $subject = bp_get_email_subject( array( 'text' =>
 sprintf( __( '%s replied to one of your updates', 'buddypress' ),
 $poster_name ) ) );
                         $message = sprintf( __(
         '%1$s replied to one of your updates:


         To view your original update and all comments, log in and visit:

         ', 'buddypress' ), $poster_name, $content, $thread_link );

                         /* Send the message */
                         wp_mail( $to, $subject, $message );
 'bp_activity_sent_reply_to_update_email', $original_activity->user_id,
 $subject, $message, $comment_id, $commenter_id, $params );

 I'll have to re-work in notification settings etc., but it's a start.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5395>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list