Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce - My Account link
<?php if ( is_user_logged_in() ) { ?>
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','woothemes'); ?>"><?php _e('My Account','woothemes'); ?></a>
<?php }
else { ?>
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','woothemes'); ?>"><?php _e('Login / Register','woothemes'); ?></a>
<?php } ?>
@shaoqifly

This comment has been minimized.

Copy link

@shaoqifly shaoqifly commented Sep 22, 2013

can i get your help to know where i can find the header.php file? Is it under ../woocommerce/templates/myaccount? Thank you.

@metalcated

This comment has been minimized.

Copy link

@metalcated metalcated commented Nov 13, 2013

Since this has since changed by reading the page title, how could we add a function to control this?

@jameskoster

This comment has been minimized.

Copy link
Owner Author

@jameskoster jameskoster commented Nov 13, 2013

@metalcated what exactly do you want to control?

@metalcated

This comment has been minimized.

Copy link

@metalcated metalcated commented Nov 13, 2013

I want to be able to change the Register / Login header the same as this code does using a function. From the best I can tell this does not work anymore.

@manesal

This comment has been minimized.

Copy link

@manesal manesal commented Feb 14, 2014

Hi James,
I have used this code and it worked fine. But I founded 2 issues:

  1. there´s no Logout option, after logged in. What´s the code to put it beside "My Account"?

  2. when I click my logo, to return to Home, I get logged out. But if i enter in any other area of the website I get logged in again. It´s strange!

Do you have any idea how to solve any of this? Thanks a lot.

@RippleWebDesign

This comment has been minimized.

Copy link

@RippleWebDesign RippleWebDesign commented Jan 12, 2015

This snippet works great for me! I would also love a log out option for users who are logged in. What is the code for that and where would it go?

@jaafarscorpion

This comment has been minimized.

Copy link

@jaafarscorpion jaafarscorpion commented Aug 6, 2015

hello how to display user logged in place my account

@Xantoru

This comment has been minimized.

Copy link

@Xantoru Xantoru commented Aug 11, 2015

Hello, I have a question. This code is it implemented in template/header.php or header.php of the theme in use?

@Hekur

This comment has been minimized.

Copy link

@Hekur Hekur commented Sep 27, 2016

Hi jameskoster,
May I know where to find header.php file.

It would be more useful if you can explain this code to us. Actually I can see "wootheme" there in code, and I am using avada theme. So will it work on avada 4.0.3

@mattmaker

This comment has been minimized.

Copy link

@mattmaker mattmaker commented Jan 11, 2017

Does this still work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment