bp_activity_remove_screen_notifications_single_post()

Mark notifications as read when a user visits an single post.

Description

Source

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

function bp_activity_remove_screen_notifications_single_post() {

	$reply_id         = filter_input( INPUT_GET, 'rid', FILTER_VALIDATE_INT );
	$comment_reply_id = filter_input( INPUT_GET, 'crid', FILTER_VALIDATE_INT );

	if (
		! is_single()
		|| (
			empty( $reply_id )
			&& empty( $comment_reply_id )
		)
	) {
		return;
	}

	$comment_id = 0;
	// For replies to a parent update.
	if ( ! empty( $reply_id ) ) {
		$comment_id = $reply_id;

		// For replies to an activity comment.
	} elseif ( ! empty( $comment_reply_id ) ) {
		$comment_id = (int) $comment_reply_id;
	}

	// 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
BuddyBoss 1.5.4 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.