bp_notifications_get_grouped_notifications_for_user( int $user_id )

Get a user’s unread notifications, grouped by component and action.


Description Description

This function returns a list of notifications collapsed by component + action. See BP_Notifications_Notification::get_grouped_notifications_for_user() for more details.


Top ↑

Parameters Parameters

$user_id

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


Top ↑

Return Return

(array) $notifications


Source Source

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

function bp_notifications_get_grouped_notifications_for_user( $user_id = 0 ) {
	if ( empty( $user_id ) ) {
		$user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
	}

	$notifications = wp_cache_get( $user_id, 'bp_notifications_grouped_notifications' );
	if ( false === $notifications ) {
		$notifications = BP_Notifications_Notification::get_grouped_notifications_for_user( $user_id );
		wp_cache_set( $user_id, $notifications, 'bp_notifications_grouped_notifications' );
	}

	return $notifications;
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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