Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save champsupertramp/b752e0dc8c2219d38a9e2a70b397bab2 to your computer and use it in GitHub Desktop.
Save champsupertramp/b752e0dc8c2219d38a9e2a70b397bab2 to your computer and use it in GitHub Desktop.
Ultimate Member - Real-time notifications - Shortcode for Menus
<?php
/**
* Add notification count tag value
* {notification_count}
*/
add_filter( ‘um_profile_tag_hook__notification_count’,‘um_custom_notification_count’, 10, 2 );
function um_custom_notification_count( $value, $user_id ){
$count = UM()->Notifications_API()->api()->get_notifications( 0, 'unread', true );
return '<span class="um-notification-unreaditems count-'. $count . '">' . ( ( $count > 10 ) ? 10 . '+' : $count ) . '</span>';
}
/**
* Add new tags pattern
*/
add_filter( 'um_allowed_user_tags_patterns', 'um_custom_notification_tags', 10, 1 );
function um_custom_notification_tags( $tags ) {
$tags[ ] = '{notification_count}';
return $tags;
}
@AaronChaos
Copy link

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