Created
July 3, 2019 15:13
-
-
Save champsupertramp/b752e0dc8c2219d38a9e2a70b397bab2 to your computer and use it in GitHub Desktop.
Ultimate Member - Real-time notifications - Shortcode for Menus
Hi @AaronChaos
You can try this one with the Menu tag {notification_count}
add_filter( 'wp_nav_menu_items', 'um_051821_notification_count', 10, 2 );
function um_051821_notification_count( $items, $args ) {
if( is_user_logged_in() && class_exists("UM_Notifications_API") ){
$count = UM()->Notifications_API()->api()->get_notifications( 0, 'unread', true );
$count = '<span class="um-notification-unreaditems count-'. $count . '">' . ( ( $count > 10 ) ? 10 . '+' : $count ) . '</span>';
$items = str_replace( '{notification_count}', $count, $items );
}
return $items;
}
Regards,
Hi @champsupertramp, that worked perfectly, thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you confirm if this compatible with the latest version of UM and the notification, add-on, please? I have included the code in my functions.php, however, the shortcode doesn't output anything when added to the menu.