Some themes include the customer avatar in the My Account page. I like it a lot, so i wrote a tutorial to add it also in Storefront, the latest WooThemes free theme – download it on WordPress.org!

The avatar will show on the left of the welcome message in your My Account page. It will show the customer photo or the “Mystery Man” from Gravatar. If you still do not have an account on Gravatar, I suggest to create one since it’ used on a lot of sites, and all sites powered by WordPress and Ghost (yep, also this one).

Ok, now it’s time to get your hands dirty. Open up your functions.php file located in wp-content/themes/your-theme-name/ and add this code in it:

Then open your style.css file in the same path and add this code:

Note: Remember to use a child theme to do this, do not edit the files in Storefront.

The first code adds the functionality. It gets the customer avatar and print it after the welcome message. But we want it before, so we add also the second code, which is some CSS adding the style to move the avatar on the left of the welcome message and some borders to make it fit in the style of Storefront.

The page should now look like this:

myaccount-storefront-avatar

Feel free to further tweak the CSS. This is only a simple example of what you can do, but the options are limitless, you can change everything and move the avatar wherever you want it.

15 replies
  1. unapplicable
    unapplicable says:

    I do trust all of the ideas you have introduced
    for your post. They’re very convincing and can definitely work.
    Nonetheless, the posts are very short for newbies.
    May you please lengthen them a little from next time?
    Thanks for the post.

    Reply
  2. David
    David says:

    Hi Nicole,

    Wow, thanks so much for this. It really helped me.

    I have a couple of questions maybe you could help me with. I inserted this code into the correct location and it works. The problem I am having is that the snippet of text next to it is now showing.

    Could you tell me what code to insert so that I can insert my own snippet next to the users profile picture in the same format? Ie colored bar next to the image and then text?

    Is there any way I can make the image circular?

    Thanks 🙂

    Reply
  3. Rodger
    Rodger says:

    Code works, but the image is after the welcome message, as per code description..
    “Print the customer avatar in My Account page, after the welcome message.”

    How does one put on the left as per screenshot example above?

    Thank you.

    Reply
  4. Winters
    Winters says:

    Nicola thank you for your article! I know this is an old post but…

    I noticed on My Account page – there was no .myaccount_user class for floating the text to the right of the avatar image.

    To get the avatar to show up in a spot that was easier to manipulate, I had to change ‘woocommerce_before_my_account’ to ‘woocommerce_account_content’

    With the suggested change, the avatar displays before the welcome message. Then all you need for your .myaccount_avatar css is your float, padding and border styles.

    I am using WP 4.9.5 with the Storefront 2.3.1 default theme, hope this makes sense and helps someone else!

    Reply
  5. Jim Worrall
    Jim Worrall says:

    Hi, this is great information. I wonder if you would be willing to show how to put the avatar in the header, but of course condition on the user being logged in. Or maybe do a separate post on that?

    Reply
  6. ErnestPH
    ErnestPH says:

    The code is not showing my image. So I modified it using get_avatar( $current_user->ID, 64 ) and it’s now showing fine.

    Thanks still for the heads up!

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

You have to agree to the comment policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.