Display User’s Name, or any of Their Other Information


I put together this very simple snippet to display a user’s name when they log in to a premium membership site. Then, to display their name, all you have to do is use the shortcode [user_first_name], and their name will appear instead (assuming it has been entered in their profile).

You can take it a little further and modify this to show other information instead by taking advantage of the other variables available under $current_user. Use the following values to show more information:

  • First name: user_firstname
  • Last name: user_lastname
  • Display name: display_name
  • Username: user_login
  • User email address: user_email
  • User ID: ID

Categories: Code & Snippets | Permalink

What next?

Hire me

If you couldn't quite manage this yourself, find it too intimidating, or just don't have the time to do it, you can always hire Dave to do it. Please get in touch so that we can discuss your needs.

Leave a comment

If you have a question, update, or comment about the tutorial, please leave a comment. I try and respond to every comment, though it may take a few days, so please check back soon.

Let a WordPress Expert help you

Do you want to try this, but feel like you need a helping hand, in case something goes wrong? My service, The WP Butler, gives you access to WordPress expertise whenever you need it. Better yet, I'll keep your site backed up, updated and secure, so that you don't have to worry about it. It's all part of the service. Use coupon DIWW and save 15% on all plans.

Visit The WP Butler


Dave has been tinkering with WordPress for many years, and he now shares his WordPress knowledge here on Do It WIth WordPress to help others realise its impressive power. He can also be hired to help with your WordPress needs. Dave, who is British, is married to his best friend, Marti, with whom he has a beautiful daughter, Ellie. When he's not dabbling with WordPress, he's probably eating Triscuits or hummus, watching an indie film or British TV show, spending time with friends or family, or exploring the world.


  1. Shouldn’t you be returning the first name sanitized with esc_attr? That’t at least what I do for any item that comes right out of the DB.

    • Point well taken Curtis. Sanitization is something I’m just getting my hands dirty with, so it’s not yet common practice for me. I’ll update the tutorial. Thanks again for the tip.

      • I just really started getting in to proper sanitization 6 months ago, but now I see issues all over with it. There is always so much to learn, we can’t start knowing everything at once.


  2. Very useful code. HTML code is better than adding widgets or plugins in a wordpress. Plugins and other extra installations slow down a website so nice and simple code for better and attractive look.

    • Actually, the idea that lots of plugins slow your site down is a misconception. This snippet is PHP (not HTML) just like any other plugin, and including it in as its own plugin, or adding it to an existing plugin, like a functionality plugin, makes no difference to its impact on your site.

      The idea that lots of plugins slow down your site is when people install lots of badly coded plugins which can impact performance. But this small snippet could be it’s own plugin and have absolutely no impact on load time at all.

Leave a Reply