Support » Theme: Virtue » Logged in user link in the top bar

  • Resolved kooor

    (@kooor)


    Hi,
    I use Virtue theme.
    I am trying to display a logged-in username as a link in the topbar which can take him to my-account when clicked.
    Though I am able to get the current user info but displaying it as a link in the top bar seems tricky.
    May be some plugin can help but I would prefer not to for such a small code.Appreciate your help.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    The easiest way to accomplish this would be to use a plugin like this one:
    https://wordpress.org/plugins/user-shortcodes/

    wrapping the shortcode with link tags to the desired page and placing it where you would like it to appear.

    Otherwise you would have to figure out a way to code it, which would be much more difficult.

    Let me know if that works for you!

    -Kevin

    Thanks Kevin! Yes, the plugin will help.If I am able to accomplish this without the plugin, will get back and write the solution here.

    Thanks
    Mehnaz

    Hi,
    Just in case, somebody comes across the same problem, here is the solution.
    I have used child-theme. In the file header-topbar.php , I added the following code

    <?php if(is_user_logged_in())  : ?>
         <li><a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('You are logged in',''); ?>">You are logged in as <?php _e( $user->display_name,''); ?></a>
      <?php else : ?>
        <li><a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('You are not logged in',''); ?>"><?php _e( 'log in',''); ?></a>
        <?php endif; ?>

    just after the existing code loops through the top-bar icons.

    -Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Logged in user link in the top bar’ is closed to new replies.