Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] How To Get Notification Count? (Code)?

@chatty24

Participant

@danbp
I have edited the code a bit and now it is getting displayed on all the pages as I wanted but, How can I hide the modified title when the notification count is 0. By current code is below –

function bpfr_add_notification_to_page_title( $title, $original_title, $sep, $seplocation  ) {
	global $bp;
	if( bp_is_user() && ! bp_get_member_user_id() ) {
        $user_id = 'displayed: '. bp_displayed_user_id();
    } else {
        $user_id = 'get_member_user: '. bp_get_member_user_id();
    }

	if (bp_notifications_get_unread_notification_count( $user_id ) ) {

		$counter = 0;
			for ( $i = 0; $i < count($notifications); $i++ ) {
				echo $notifications[$i];
			$counter++;
			}	

	
		
			$title = "You Have " . bp_notifications_get_unread_notification_count() . " New Notification(s) - ";
    
		return $title;
	}
}
add_filter( 'wp_title', 'bpfr_add_notification_to_page_title', 9, 4 );

Thanks

Skip to toolbar