WordPress :: get author info outside the loop

Image via Wikipedia

I’m working on a plugin to which will ftp posts each time they are published.  It’s going pretty good – but the only information I have on the author is the ID.  So I needed to get more about the author – I found the solution in a post by Shawn Gaffney which showed me how:

WordPress allows you to create a custom Author web page for your WordPress blog and you can make this page look like anything you want. It is easy to display author’s profile inside the WordPress loop. However, it can be a challenge when you have multi-users blog and trying to dynamically display author profile for the current post on the single page using sidebar or widget.

// Get the author profile data using author’s ID ($author)
if(isset($_GET[‘author_name’])) {
$curauth = get_userdatabylogin(get_the_author_login());
} else {
$curauth = get_userdata(intval($author));

Then use:  $curauth->display_name; to get the name.

Jump over to Shawn’s site to see how to get all the author information you need.

Also – another good post about the author loop is here.

Reblog this post [with Zemanta]