Skip to:
Content
Pages
Categories
Search
Top
Bottom

Getting the unread-count inbox-count info elsewhere

  • Avatar of smuddah
    smuddah
    Participant

    @smuddah

    i’m looking for a way to display the unread messages info (which looks like this in html)

    <span class="unread-count inbox-count" style="display: inline;">1</span>

    to be in the footer of my site.

    is there a snippet for it?

Viewing 11 replies - 1 through 11 (of 11 total)
  • bp_adminbar_notifications_menu() is the function to call for creating the notifications menu… you will have to play with that.

    Avatar of smuddah
    smuddah
    Participant

    @smuddah

    oh, i thought there might be an easier way. like <?php bp_show_unread_count() ?> :D

    you can easily recreate a new function with the one i provided, so instead of creating a dropdown menu it would simply show a count…

    Avatar of smuddah
    smuddah
    Participant

    @smuddah

    thanks nexia, i will checkout the docu.

    Avatar of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    <?php bp_total_unread_messages_count() ?>

    Avatar of Simon Dabkowski
    Simon Dabkowski
    Participant

    @simoncreative

    Here’s what I use:

    <?php

    global $bp;

    $hmag_inbox_count = messages_get_unread_count();

    if ($hmag_inbox_count > ’9′) {

    $hmag_inbox_count = ’9+’;

    }

    echo ‘<span class=”your-style”>’.$hmag_inbox_count.’</span>’;

    ?>

    Displays a number for # of unread. If the count is greater then 9, it displays 9+

    Avatar of smuddah
    smuddah
    Participant

    @smuddah

    i want my personal andy peatling right beside me when i play with buddypress.

    thanks a lot everyone!

    even tho the code doesn’t check for »pendig friendships« it’s pretty cool!

    <?php bp_total_unread_messages_count() ?>

    having a Andy Peatling in my living room when i code, would be really annoying… sorry but we would have to debate the usage of each function… not good.

    ROFL!

    Avatar of smuddah
    smuddah
    Participant

    @smuddah

    i thought <?php bp_core_get_notifications_for_user() ?> might get all notifications, but that’s just empty. hmm

    Avatar of drebabels
    drebabels
    Member

    @drebabels

    Just a note “ echos the count.
    If you want to return the count without the echo use “

    Avatar of adamt19
    adamt19
    Participant

    @adamt19

    Bumping to re-post the information that @drebabels posted but looks to have been lost due to use of quotes

    bp_total_unread_messages_count() uses echo. So if you use this within an ‘echo’ you’ll get unexpected results (value doesn’t print where you expect it to in the DOM, in my experience)

    add ‘get’, e.g. bp_get_total_unread_messages_count() to simply return the # of messages for the logged-in user in your code

Viewing 11 replies - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.