diff --git a/src/bp-messages/bp-messages-notifications.php b/src/bp-messages/bp-messages-notifications.php
index e2855d746..cb7eff9e0 100644
a
|
b
|
add_action( 'thread_loop_start', 'bp_messages_screen_conversation_mark_notificat |
261 | 261 | * @since 3.0.0 |
262 | 262 | * |
263 | 263 | * @param int $thread_id ID of the thread being marked as read. |
| 264 | * @param int $user_id ID of the user thread will be marked as unread. |
| 265 | * @param int $num_rows The number of affected rows by the "mark read" update query. |
264 | 266 | */ |
265 | | function bp_messages_mark_notification_on_mark_thread( $thread_id ) { |
| 267 | function bp_messages_mark_notification_on_mark_thread( $thread_id, $user_id, $num_rows = 0 ) { |
| 268 | if ( ! $num_rows ) { |
| 269 | return; |
| 270 | } |
| 271 | |
266 | 272 | $thread_messages = BP_Messages_Thread::get_messages( $thread_id ); |
267 | 273 | |
268 | 274 | foreach ( $thread_messages as $thread_message ) { |
269 | | bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $thread_message->id, buddypress()->messages->id, 'new_message' ); |
| 275 | bp_notifications_mark_notifications_by_item_id( $user_id, $thread_message->id, buddypress()->messages->id, 'new_message' ); |
270 | 276 | } |
271 | 277 | } |
272 | | add_action( 'messages_thread_mark_as_read', 'bp_messages_mark_notification_on_mark_thread' ); |
| 278 | add_action( 'messages_thread_mark_as_read', 'bp_messages_mark_notification_on_mark_thread', 10, 3 ); |
273 | 279 | |
274 | 280 | /** |
275 | 281 | * When a message is deleted, delete corresponding notifications. |
diff --git a/src/bp-messages/classes/class-bp-messages-thread.php b/src/bp-messages/classes/class-bp-messages-thread.php
index bc5f93a5e..2fe779c0f 100644
a
|
b
|
class BP_Messages_Thread { |
655 | 655 | bp_loggedin_user_id(); |
656 | 656 | } |
657 | 657 | |
658 | | $bp = buddypress(); |
659 | | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
| 658 | $bp = buddypress(); |
| 659 | $num_rows = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
660 | 660 | |
661 | 661 | wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); |
662 | 662 | wp_cache_delete( $user_id, 'bp_messages_unread_count' ); |
… |
… |
class BP_Messages_Thread { |
666 | 666 | * |
667 | 667 | * @since 2.8.0 |
668 | 668 | * @since 9.0.0 Added the `user_id` parameter. |
| 669 | * @since 10.0.0 Passes the number of affected rows into the action. |
669 | 670 | * |
670 | 671 | * @param int $thread_id The message thread ID. |
671 | 672 | * @param int $user_id The user the thread will be marked as read. |
| 673 | * @param bool|int $num_rows Number of threads marked as unread or false on error. |
672 | 674 | */ |
673 | | do_action( 'messages_thread_mark_as_read', $thread_id, $user_id ); |
| 675 | do_action( 'messages_thread_mark_as_read', $thread_id, $user_id, $num_rows ); |
674 | 676 | |
675 | | return $retval; |
| 677 | return $num_rows; |
676 | 678 | } |
677 | 679 | |
678 | 680 | /** |
… |
… |
class BP_Messages_Thread { |
699 | 701 | bp_loggedin_user_id(); |
700 | 702 | } |
701 | 703 | |
702 | | $bp = buddypress(); |
703 | | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
| 704 | $bp = buddypress(); |
| 705 | $num_rows = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
704 | 706 | |
705 | 707 | wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); |
706 | 708 | wp_cache_delete( $user_id, 'bp_messages_unread_count' ); |
… |
… |
class BP_Messages_Thread { |
710 | 712 | * |
711 | 713 | * @since 2.8.0 |
712 | 714 | * @since 9.0.0 Added the `$user_id` parameter. |
713 | | * @since 10.0.0 Added the `$retval` parameter. |
| 715 | * @since 10.0.0 Added the `$num_rows` parameter. |
714 | 716 | * |
715 | 717 | * @param int $thread_id The message thread ID. |
716 | 718 | * @param int $user_id The user the thread will be marked as unread. |
717 | | * @param bool|int $retval =Number of threads marked as unread or false on error. |
| 719 | * @param bool|int $num_rows Number of threads marked as unread or false on error. |
718 | 720 | */ |
719 | | do_action( 'messages_thread_mark_as_unread', $thread_id, $user_id, $retval ); |
| 721 | do_action( 'messages_thread_mark_as_unread', $thread_id, $user_id, $num_rows ); |
720 | 722 | |
721 | | return $retval; |
| 723 | return $num_rows; |
722 | 724 | } |
723 | 725 | |
724 | 726 | /** |