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.


Parameters Parameters

$user_id

(int) (Required) User ID.

$status

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

Default value: 'is_new'


Top ↑

Return Return

(array) Associative array


Source 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 '
			: '';

		$query   = "SELECT * FROM {$bp->notifications->table_name} WHERE user_id = %d {$is_new}";
		$prepare = $wpdb->prepare( $query, $user_id );
		$result  = $wpdb->get_results( $prepare );

		return $result;
	}


Top ↑

User Contributed Notes User Contributed Notes

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