Hi there, I have added messages in a sub-navigation hook element,and I want to add the message count as well.
But I don’t know which value I should add for it to display. Can you help me with information, where the count is populated and which to use?
<div class="grid-container sub-navigation grid-parent"> <ul> <li id="messages-personal-li" > <a href="https://domain/members/me/messages/" id="user-messages" class="menu-item menu-item-type-post_type menu-item-object-post messages-personal-li button"> Messages <span class="count"></span> </a> </li> </ul> </div>
Thanks in advance
CarstenHi,
You can use the following code<?php echo bp_get_total_unread_messages_count( $user_id );?>
Where you can use following for user id
bp_loggedin_user_id(); // of the logged in user bp_displayed_user_id(); // of the displayed user bp_get_member_user_id();// in members loop
Depending on the context.
Regards
BrajeshHi Carsten,
Yes, that is the correct function.Regards
BrajeshHi Brajesh, thanks, I found out that
visitors_get_unique_visitors_count
must be the correct one, or?One more question to this markup of the class below, which is probably not correct, It seems like defining the class below is redundant, as it has no effect?
<li id="visitors-personal-li"> <a href="https://domain/members/me/visitors/" id="user-visitors" class="recent-visitors-for-buddypress-profile" > Besøg <span class="count"></span> </a> <?php echo visitors_get_unique_visitors_count( bp_loggedin_user_id() ); ?> </li>
The correct class must be something like the one for messages defining the button:
class="menu-item menu-item-type-post_type menu-item-object-post messages-personal-li button"
but I don’t know where to look it up?
Regards
CarstenHi Carsten,
Both the functions are correct. Depends on your need. One provides unique count while other provide total count(including repeated visits).About the nav, I am sorry but I am not in a position to assist you. I do not think I understand the context well to assist you.
You are most probably doing it for a custom theme and a lot of markup will depend on what the theme expects.
Regards
Brajesh
The topic ‘ [Resolved] Adding message count to Messages in a hook element’ is closed to new replies.