Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #642268

    Hi,

    Can anyone help me to show username with the link to my account page instead of links which is shown when user not logged in?

    Many thanks.

    #642449

    Hi supermanikin,

    I’m not sure if that could be achieved easily but send us a link to your page and we’ll have a look at it.

    Best regards,
    Rikard

    #642464

    I’m setting the secondary menu to that and still do not find any solution to make it automatically change after user logged in to “Welcome [username] Logout”.

    Do you have any easy solution for that ?

    Many thanks.

    #642640

    Hi,

    Please add following code to Functions.php file of your child theme in Appearance > Editor

    function avia_username_sc(){
    $current_user = wp_get_current_user();
    if(is_user_logged_in ()){
    $output = '<span class="custom-un">Welcome ' . $current_user->user_login . '</span>';
    }
    else {
    $output = '<a href="'.wp_login_url().'" title="Login" rel="nofollow">Login</a>';
    }
    return $output;
    }
    add_shortcode( 'username', 'avia_username_sc' );
    add_filter('wp_nav_menu_items', 'do_shortcode');

    then go to Appearance > Menus and a new custom link to your secondary menu with # for URL and [username] for navigation label.

    Best regards,
    Yigit

    • This reply was modified 9 years, 9 months ago by Yigit.
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.