BP_Notifications_Notification::get_current_notifications_for_user( array $args = array() )

Get unread notifications for a user, in a pagination-friendly format.


Description Description


Parameters Parameters

$args

(Optional) Array of arguments.

  • 'user_id'
    (int) ID of the user for whom the notifications are being fetched. Default: logged-in user ID.
  • 'is_new'
    (bool) Whether to limit the query to unread notifications. Default: true.
  • 'page'
    (int) Number of the page to return. Default: 1.
  • 'per_page'
    (int) Number of results to display per page. Default: 10.
  • 'search_terms'
    (string) Optional. A term to search against in the 'component_name' and 'component_action' columns.

Default value: array()


Top ↑

Return Return

(array)

  • 'notifications'
    (array) Array of notification results.
  • 'total'
    (int) Count of all located notifications matching the query params.


Top ↑

Source Source

File: bp-notifications/classes/class-bp-notifications-notification.php

	public static function get_current_notifications_for_user( $args = array() ) {
		$r = wp_parse_args( $args, array(
			'user_id'      => bp_loggedin_user_id(),
			'is_new'       => true,
			'page'         => 1,
			'per_page'     => 25,
			'search_terms' => '',
		) );

		$notifications = self::get( $r );

		// Bail if no notifications.
		if ( empty( $notifications ) ) {
			return false;
		}

		$total_count = self::get_total_count( $r );

		return array( 'notifications' => &$notifications, 'total' => $total_count );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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