Hi Ravi,
Thank you for your reply 🙂
Unfortunately, that leads to a fatal error ‘undefined function’. I am adding it like so:
<a id="user-messages" href="/messages/" class="msg">Messages <span class="alert_count"><?php if( class_exists( 'Buddypress' ) ) {echo messages_get_unread_count( $user_id = 0 );} ?></span></a>
Hi Mwale,
1. Please make sure you have BuddyPress Messages component enable where you are trying to use the function.
2. For fetching current user’s count, you can use
<a id="user-messages" href="/messages/" class="msg">Messages <span class="alert_count"><?php if( class_exists( 'Buddypress' ) ) {echo messages_get_unread_count( get_current_user_id() );} ?></span></a>
I do suggest that instead of checking for BuddyPress class, you might want to check function_exists for the above function. That way, if messages component is disabled, it won’t cause fatal error.
Regards
BrajeshThank you MWale,
Glad that it worked.
Have a great day 🙂Regards
Brajesh
The topic ‘ [Resolved] Buddypress Unread Message Count’ is closed to new replies.