Show buddypress notification in the frontend [closed]

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="https://wordpress.stackexchange.com/questions/84072/<?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()?>

Leave a Comment