Show buddypress notification in the frontend

I’ve a buddypress website and what I want is to show in the frontend the notification that buddybar have in the backend, but only the notification not all the buddybar.

basically set the notification like facebook….

Read More

how can I do that?

Related posts

Leave a Reply

2 comments

  1. Put the following code in your functions.php. If you want a demo i can show you.

    // my custom notification menu www.cityflavourmagazine.com
    
    function my_bp_adminbar_notifications_menu() {
    global $bp;
    
    if ( !is_user_logged_in() )
        return false;
    
    echo '<li id="top-notification">';
    _e( 'Alerts', 'buddypress' );
    
    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
        <span><?php echo count( $notifications ) ?></span>
    <?php
    }
    
    echo '</a>';
    echo '<ul>';
    
    if ( $notifications ) {
        $counter = 0;
        for ( $i = 0; $i < count($notifications); $i++ ) {
            $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
    
            <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
    
            <?php $counter++;
        }
    } else { ?>
    
        <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'You have no new alerts.', 'buddypress' ); ?></a></li>
    
    <?php
    }
    
    echo '</ul>';
    echo '</li>';
    }
    

    Use the following code to call it anywhere you like. Note: you can amend the above code as you like

    <?php my_bp_adminbar_notifications_menu()?>

  2. look at this page
    http://www.colegeissinger.com/blog/2012/12/04/get-buddypress-notifications-count/
    where he explains like below:

    Put that function into your functions.php file

        function cg_current_user_notification_count() {
        $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object');
        $count = !empty($notifications) ? count($notifications) : 0;
    
        echo $count;
         }
    

    in front end use,

    Notificaitons : <?php cg_current_user_notification_count(); ?>