Skip to:
Content
Pages
Categories
Search
Top
Bottom

Notification count if 0 dont display?


  • jameshh93
    Participant

    @jameshh93

    At moment im using this code which display 0 if there are no notifcations how can I display nothing if there are 0 notifcations?

    echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );

    Also is there a same sort of code for friends count too and or mentions?

    Thank you!

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

  • Henry Wright
    Moderator

    @henrywright

    Try this:

    $count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
    if ( $count > 0 ) {
        echo $count;
    } else {
        // The notif count is 0.
    }

    jameshh93
    Participant

    @jameshh93

    great thank you! 🙂

    although im struggling with the friend request count as it seems to just ignore the if statement

    user_login . ‘/friends/requests/’; ?>”><i class=”fa fa-users” aria-hidden=”true”></i>

    ` <?php

    $friend_requests_count = bp_friend_total_requests_count( bp_loggedin_user_id() );
    if ( $friend_requests_count < 0 ) {
    echo ‘<div class=”site-header-user-friend-requests-bubble”>’; echo $friend_requests_count; echo ‘</div>’;
    } else {
    echo ‘<div class=”display-none”></div>’;

    }

    ?>`

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar