Reply To: [Resolved] How To Get Notification Count? (Code)?
Hi Chaitanya,
Try this code.
function bpfr_add_notification_to_page_title( $title, $original_title, $sep ) {
//do not change if the user is not logged in
if( ! is_user_logged_in() )
return $title;
$user_id = get_current_user_id();//logged in user's id
$count = bp_notifications_get_unread_notification_count( $user_id );
if( $count > 0 )
$title = sprintf( "You Have %d New Notification(s) - ", $count );
return $title;
}
add_filter( 'wp_title', 'bpfr_add_notification_to_page_title', 100, 3 );
I have modified the code from your last post. The difference is, It only does it for logged in users. Also, I have decreased the priority to make it work on BuddyPress pages( otherwide bp_modify_title would have overwritten it).
Hope that helps.