Wordpress Author Information, check if logged in
One of the sites that I operate is a site called I Choose Indy!. The site invites anyone from central Indiana to post why they chose Indy for their home or business.
Tonight I wanted to update the 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(); ?><br />
<strong>Website: </strong><a href="<?php the_author_url(); ?>"><?php
the_author_url(); ?></a><br />
<strong>About: </strong><?php the_author_description(); ?><br />
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 } ?>
</p>
I added a class=author to the style sheet to make it look nice as well (check it out at I Choose Indy! under each post).
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!