bp_activity_remove_screen_notifications_single_activity_permalink( BP_Activity_Activity $activity )

Mark notifications as read when a user visits an activity permalink.

Description

Parameters

$activity

(Required) Activity object.

Source

File: bp-activity/bp-activity-notifications.php

263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
function bp_activity_remove_screen_notifications_single_activity_permalink( $activity ) {
    if ( ! is_user_logged_in() ) {
        return;
    }
 
    // Mark as read any notifications for the current user related to this activity item.
    bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
 
    $comment_id = 0;
    // For replies to a parent update.
    if ( ! empty( $_GET['rid'] ) ) {
        $comment_id = (int) $_GET['rid'];
 
    // For replies to an activity comment.
    } elseif ( ! empty( $_GET['crid'] ) ) {
        $comment_id = (int) $_GET['crid'];
    }
 
    // Mark individual activity reply notification as read.
    if ( ! empty( $comment_id ) ) {
        BP_Notifications_Notification::update(
            array(
                'is_new' => false
            ),
            array(
                'user_id' => bp_loggedin_user_id(),
                'id'      => $comment_id
            )
        );
    }
}

Changelog

Changelog
Version Description
BuddyPress 3.2.0 Marks replies to parent update and replies to an activity comment as read. BuddyPress 3.2.0 Marks replies to parent update and replies to an activity comment as read.
BuddyPress 2.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.