[buddypress-trac] [BuddyPress Trac] #5384: All @-mention notifications cleared when anonymous user visits another user's activity feed

buddypress-trac noreply at wordpress.org
Tue Feb 11 15:24:33 UTC 2014


#5384: All @-mention notifications cleared when anonymous user visits another
user's activity feed
-----------------------------------+---------------------------
 Reporter:  SlothLoveChunk         |       Owner:  boonebgorges
     Type:  defect (bug)           |      Status:  closed
 Priority:  normal                 |   Milestone:  1.9.3
Component:  Notifications          |     Version:  1.9.1
 Severity:  critical               |  Resolution:  fixed
 Keywords:  has-patch 2nd-opinion  |
-----------------------------------+---------------------------

Comment (by henry.wright):

 > Shouldn't an @-mention also be marked as read when the user visits the
 page / post where they were mentioned in said comment?

 @boonebgorges and @johnjamesjacoby

 Would something like this work?

 {{{
 function mark_read_single_at_mention_notification( $post_id ) {

     $user_id = bp_loggedin_user_id();

     $notifications = BP_Notifications_Notification::get( array(
         'user_id' => $user_id,
         'is_new' => true,
     ) );

     if ( $notifications ) {
         foreach( $notifications as $notification ) {

         // get the activity details
         $activity = new BP_Activity_Activity( $notification->item_id );

         if ( isset( $activity ) ) {
             $comment = get_comment( $activity->secondary_item_id );

             if ( $comment ) {
                 $id = $comment->comment_post_ID;

                 if ( $id == $post_id ) {
                     bp_notifications_mark_notifications_by_item_id(
 bp_loggedin_user_id(), $notification->item_id, 'activity',
 'new_at_mention' );
                 }
             }
         }
     }
 }

 }
 add_action( 'bp_before_post', 'mark_read_single_at_mention_notification'
 );
 }}}

 One caveat is this requires a do action hook {{{bp_before_post}}} in
 single.php

 I suppose ''in theory'' the same can be done for private messages (i.e.
 when the thread is visited)

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


More information about the buddypress-trac mailing list