ap_count_unseen_notifications( integer $user_id = false )

Description #

Count total numbers of unread notifications of a user.

Parameters #

  • $user_id
    integer (Optional) User id. Default value: false

Source #

File: addons/notifications/functions.php

function ap_count_unseen_notifications( $user_id = false ) {
	if ( false === $user_id ) {
		$user_id = get_current_user_id();
	}

	global $wpdb;

	$count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM {$wpdb->prefix}ap_notifications WHERE noti_user_id = %d AND noti_seen = 0", $user_id ) ); // phpcs:ignore WordPress.DB

	return $count;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment