BP_Core_Notification::get_all_for_user( int $user_id, string $status = 'is_new' )

Fetches all the notifications in the database for a specific user.

Description

Parameters

$user_id

(int) (Required) User ID.

$status

(string) (Optional) 'is_new' or 'all'.

Default value: 'is_new'

Return

(array) Associative array

Source

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

	public static function get_all_for_user( $user_id, $status = 'is_new' ) {
		global $wpdb;

		$bp = buddypress();

		$is_new = ( 'is_new' === $status )
			? ' AND is_new = 1 '
			: '';

		return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d {$is_new}", $user_id ) );
	}

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.