bp_activity_remove_screen_notifications_single_activity_permalink( BP_Activity_Activity $activity )

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


Description Description


Parameters Parameters

$activity

(Required) Activity object.


Top ↑

Source Source

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

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
			)
		);
	}
}

Top ↑

Changelog Changelog

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

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.