Skip to:
Content

bbPress.org

Changeset 7307


Ignore:
Timestamp:
06/26/2025 12:32:48 AM (6 months ago)
Author:
johnjamesjacoby
Message:

Extend - BuddyPress - Notifications: redirect to reply when clicking a notification.

This change ensures that members are redirected to the appropriate reply URL rather than the parent topic URL.

It also now marks replies before marking the topic, and combines the updated rows together.

Props cjerrells.

In branches/2.6, for 2.6.14.

Fixes #3638.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/extend/buddypress/notifications.php

    r7184 r7307  
    207207    if ( ! bbp_has_errors() ) {
    208208
     209        // Default to nothing marked
     210        $reply_marked = $topic_marked = $marked = false;
     211
    209212        // Get these once
    210213        $post_type = bbp_get_reply_post_type();
    211214        $component = bbp_get_component_name();
    212 
    213         // Attempt to clear notifications for this topic
    214         $marked    = bp_notifications_mark_notifications_by_type( $user_id, $component, 'bbp_new_reply_' . $topic_id );
     215        $c_action  = 'bbp_new_reply_' . $topic_id;
    215216
    216217        // Get all reply IDs for the topic
     
    223224            foreach ( $replies as $reply_id ) {
    224225
    225                 // Attempt to mark notification for this reply ID
    226                 $marked = bp_notifications_mark_notifications_by_item_id( $user_id, $reply_id, $component, 'bbp_new_reply' );
     226                // Attempt to clear notification for this user & reply ID
     227                $reply_marked = bp_notifications_mark_notifications_by_item_id( $user_id, $reply_id, $component, $c_action );
    227228
    228229                // If marked, redirect to this reply ID
    229                 if ( ! empty( $marked ) ) {
     230                if ( ! empty( $reply_marked ) ) {
    230231                    $redirect_id = $reply_id;
    231232                }
     
    233234        }
    234235
     236        // Attempt to clear notifications for this user & topic
     237        $topic_marked = bp_notifications_mark_notifications_by_type( $user_id, $component, $c_action );
     238
     239        // Maybe combine updated/marked rows
     240        if ( is_numeric( $topic_marked ) || is_numeric( $reply_marked ) ) {
     241            $marked = (int) $topic_marked + (int) $reply_marked;
     242        }
     243
    235244        // Do additional subscriptions actions
    236245        do_action( 'bbp_notifications_handler', $marked, $user_id, $topic_id, $action );
Note: See TracChangeset for help on using the changeset viewer.