Mentions Count and Displaying Zero
-
Hi,
I am trying to show the number of new mentions associated with the logged in users profile.
I have found this page http://buddydev.com/support/forums/topic/at-mention-notification/ … I have used the last code provided by @sbrajesh
//at mention add_action( 'bp_adminbar_menus', 'user_show_mentione_count_in_adminbar',20 ); function user_show_mentione_count_in_adminbar(){ global $bp; if(!is_user_logged_in()||!($count=get_user_meta( $bp->loggedin_user->id, 'bp_new_mention_count' ,true))) return; //clear it because bp won't do it on profile if(bp_is_home ()&&$bp->current_component==BP_ACTIVITY_SLUG&&$bp->current_action=="mentions") delete_user_meta($bp->loggedin_user->id, 'bp_new_mention_count'); //show mentions echo "<li ><a href='".bp_get_loggedin_user_link().BP_ACTIVITY_SLUG."/mentions/'>New mentions(".$count.")</a></li>"; }
The only thing I have changed is the last line as I don’t want a link or any HTML outputted. Just the count (even if it’s zero).
echo "<li ><a href='".bp_get_loggedin_user_link().BP_ACTIVITY_SLUG."/mentions/'>New mentions(".$count.")</a></li>";
to
echo $count;
It works just fine except for one thing…
When the user has no new mentions I can’t get the code to display a ‘0’. It displays nothing at all.
I’m pretty sure this must be a simple fix but I’ve stared at it for ages now and haven’t managed it.
Can anyone help?
- The topic ‘Mentions Count and Displaying Zero’ is closed to new replies.