Content Marketing

WordPress Author: Add an Edit Profile Link if Logged In

I wanted to update a WordPress site and add an ‘About the Author’ section under every post. It was a little tougher than I thought – and actually requires even more programming, but here’s the first cut:

<p class="author">
<strong>The Author: </strong><?php the_author(); ?>
<strong>Website: </strong><a href="<?php the_author_url(); ?>"><?php the_author_url(); ?></a>
<strong>About: </strong><?php the_author_description(); ?></p>

Next, I check to see if someone is actually logged in and display an Edit Profile link so the person can simply click and update their information (I updated this post … great comment and question from Ajay!):

<?php get_currentuserinfo();
global $user_ID;
if ('' != $user_ID) { ?>
<a href="/wp-admin/user-edit.php?user_id=<?php the_author_ID(); ?>">Edit Profile</a>
<?php } ?>

I added the class=”author” to the style sheet to make it look nice as well.

I’d like to clean up the code to not show an address or info if there is none; however, I think I’m going to have to script actual queries to the database for this. Note the “Edit Profile” link… it’s wrapped by an if statement that will only display it if a user is logged in. I thought it was kind of cool, so I wanted to share it with you in case you wanted to use it!

Douglas Karr

Douglas Karr is the founder of the Martech Zone and a recognized expert on digital transformation. Douglas has helped start several successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to launch his own platforms and services. He's a co-founder of Highbridge, a digital transformation consulting firm. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles


  1. Hi Ajay!

    I don’t want to show the Edit Profile link unless someone is actually logged in. So the function get_currentuserinfo() will bring back user information and the if statement verifies if the current user has a user_id… it’s a means of checking whether or not they are logged in.

    In other words – if you are logged in, you see a link to edit profile. If you are not, you don’t see that link.


  2. Hi Doug,
    just wondering do you know how i could use this depending on the user who is logged in?
    So if the user logged in was JohnSmith it would display ‘A’ and if the user logged in was BillBob it would display ‘B’ ?


    1. Hi Mike,

      I’m pretty sure that the variable $user_id will return the actual User ID within your Users section in admin. So you might be able to build a case statement of if logic….

      if ($user_id=="1") { echo "Doug"; }

      I’ve not tested this but I’m pretty sure you have to put it within the context of the get_currentuserinfo function.


  3. Hi Doug. Thanks for sharing. Unfortunately, this code did not work for me:

    <a href=”/wp-admin/user-edit.php?user_id=”>Edit

    I used the code below instead. When a user is logged in, “My Profile” will show. When no user is logged in, “Create an Account” appears.

    < ?php if (is_user_logged_in()){
    echo (‘My Profile‘);
    else {
    echo (‘Create an Account‘);

    Just want to share in case someone else needs it. 🙂 Please remove the space between “<” and “?” for the code to work.

What do you think?

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


Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.