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

buddypress-trac noreply at wordpress.org
Thu Feb 13 10:41:09 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       |  Resolution:
 Keywords:               |
-------------------------+------------------------------

Comment (by terraling):

 I'll just toss in here that I had to tweak the messages so that they say
 something like:

 "Jack commented on their update",
 "Jill commented on Jack's update", or
 "John commented on your update".

 Code then looks like:


 {{{
 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

         $original_activity = new BP_Activity_Activity( $activity_id );
         $op = $original_activity->user_id;
         $op_name = bp_core_get_user_displayname( $op );

         $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 ( $op == $user_id ) { // is it the OP commenting on their own
 update?
                 $notice = sprintf( __( "%s commented on their update",
 "buddypress" ), $poster_name );
         } else {
                 $notice = sprintf( __( "%s commented on %s's update",
 "buddypress" ), $poster_name, $op_name );
         }
         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;
                         if ( $conversation_id == $op ) {
                                 $notice = sprintf( __( "%s commented on
 your update", "buddypress" ), $poster_name );
                         }
                         $subject = bp_get_email_subject( array( 'text' =>
 $notice ) );
                         $message = $notice . ":\r\n\r\n" . sprintf( __(
 '"%1$s"

 To view the original update and all comments visit: %2$s
 ', 'buddypress' ), $content, $thread_link );

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

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


More information about the buddypress-trac mailing list