Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding "Notifications" to wp_nav_menu_items

  • @intermike

    Participant

    I’m trying to put the notifications in a new sub nav, but I can’t get it to work. This is what I have:

    add_filter('wp_nav_menu_items','custom_nav_items',10,2);
    function custom_nav_items($menu, $args) {
    global $bp;
    $args = (array)$args;
    if ( is_user_logged_in() ) {
    if ( $args != 'primary' )
    return $menu;
    $customNav = '<li class="menu-item menu-item-type-post_type menu-item-object-page ss-nav-menu-item-5 ss-nav-menu-item-depth-0 ss-nav-menu-reg ss-nav-menu-mega-alignRight customNav"><a>loggedin_user->domain .'">'. $bp->loggedin_user->fullname .'</a>
    <ul class="sub-menu sub-menu-1">
    <li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a>loggedin_user->domain .'">View Profile</a></li>
    <li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a>loggedin_user->domain .'profile/edit/">Edit Profile</a></li>
    <li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a>loggedin_user->domain .'settings/change-avatar">Change Photo</a></li>
    <li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a>loggedin_user->domain .'settings/">Edit Settings</a></li>
    <li class="menu-item menu-item-type-custom menu-item-object-custom ss-nav-menu-item-depth-1"><a href="'. wp_logout_url( bp_get_root_domain() ) .'">Logout</a></li>
    <ul>
    </li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page ss-nav-menu-item-5 ss-nav-menu-item-depth-0 ss-nav-menu-reg ss-nav-menu-mega-alignRight"><a href="#">Notifications';
    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) {
    '<span>' echo count($notifications) '</span>'
    }
    echo '</a>';
    echo '<ul>';
    if ( $notifications ) {
    $counter = 0;
    for ( $i = 0; $i < count($notifications); $i++ ) {
    $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    '<li>' echo $notifications[$i] '</li>'
    $counter++;
    }
    } else {
    '<li><a href="#">No new notifications</a></li>'
    }
    echo '</ul>';
    echo '</li>';
    if( function_exists('my_bp_adminbar_notifications_menu') ) my_bp_adminbar_notifications_menu();
    return $menu.$customNav;
    } else {
    $loggedoutNav = '<li class="menu-item menu-item-type-post_type menu-item-object-page ss-nav-menu-item-5 ss-nav-menu-item-depth-0 ss-nav-menu-reg ss-nav-menu-mega-alignRight"><a style="font-weight: bold;color: red" href="signup/">Sign Up!</a></li>';
    return $menu.$loggedoutNav;
    }
    }

    I’m also trying to stick “Messages (#)” up there, too, but haven’t tried yet.

    Anyone know why it’s not working?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding "Notifications" to wp_nav_menu_items’ is closed to new replies.
Skip to toolbar