Add shop logout link with user name

add_filter( 'wp_nav_menu_items', 'ATK_add_loginout_link', 10, 2 );
function ATK_add_loginout_link( $items, $args ) {
    if (is_user_logged_in() && $args->theme_location == 'shop-menu') {
    	$user=wp_get_current_user();
        $name=$user->user_firstname;
        $items .= '<li><span class=menu-username">Welcome '.$name.'!</span></li>
        <li><a href="'. wp_logout_url() .'">Log Out</a></li>';

    }
    elseif (!is_user_logged_in() && $args->theme_location == 'shop') {
        $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
    }
    return $items;
}
No Comments

Sorry, the comment form is closed at this time.