Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Adding profile link to Menu

@daileycon

Participant

I DID IT!!!! Now this adds an edit profile link in my top bar menu only if someone is logged in! Whooo hooo

add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ($menu , $args ) {
    if (is_user_logged_in() && $args->theme_location == 'topbar_navigation') {
        $current_user = wp_get_current_user();
        $user=$current_user->user_nicename ;
        $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
        $menu = $menu . $profilelink;
    }
    return $menu;
}
Skip to toolbar