bp_notifications_mark_notifications_by_type( int $user_id, string $component_name, string $component_action, int|bool $is_new = false )

Mark notifications read/unread for a user by type.

Description

Used when clearing out notifications for a specific component when the user has visited that component.

Parameters

$user_id

(int) (Required) ID of the user whose notifications are being deleted.

$component_name

(string) (Required) Name of the associated component.

$component_action

(string) (Required) Name of the associated action.

$is_new

(int|bool) (Optional) 0 for read, 1 for unread.

Default value: false

Return

(int|false) True on success, false on failure.

Source

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

function bp_notifications_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new = false ) {
	return BP_Notifications_Notification::update(
		array(
			'is_new' => $is_new
		),
		array(
			'user_id'          => $user_id,
			'component_name'   => $component_name,
			'component_action' => $component_action
		)
	);
}

Changelog

Changelog
Version Description
BuddyPress 1.9.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.