Hmm, kinda works. I’m using BuddyPress, by the way. Too bad there isn’t anything like Widget Context for menu items. I’m looking to add custom nav menu items like so:
Mike
– Edit Profile
– Change Settings
– Logout
I’ve managed to add links to the menu with this:
/** add custom nav menu items **/
add_filter('wp_nav_menu_items','custom_nav_items',10,2);
function custom_nav_items($menu, $args) {
global $bp;
$args = (array)$args;
if ( $args['theme_location'] != 'primary' )
return $menu;
$customNav = '<li class="customNav"><a href="'. $bp->loggedin_user->domain .'">'. $bp->loggedin_user->fullname .'</a>
<ul class="sub-menu sub-menu-1">
<li class="subNav"><a href="'. $bp->loggedin_user->domain .'">'. $bp->loggedin_user->fullname .'</a></li>
<ul>
</li>';
return $menu.$customNav;
}
Is this okay, or is there a better way to do this? Also, how might I put conditions around sub nav items/dropdowns as well? Would the following work if placed before the dropdown?:
if ( is_user_logged_in() ) {
echo '<ul><li>Sub Nav Here</li></ul>';
}