Fahdi’s Personal Blog

Here I share my web ideas

WP plugin: Get Author Profile

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
June23

WP plugin: Get Author Profile

Get Author Profile is a pretty basic WordPress plugin that lets you manually access an author’s (i.e. user’s) profile. The main purpose is to let you provide author information outside The Loop, such as for a sidebar intro of the blog owner or to list contributors to your blog.

(Note to WordPress 1.2 users: This is now a WordPress 1.5+ plugin. See the July 9th update.)

When the get_author_profile() function is called with a specific numeric User ID, you can make use of global variables related to that author’s profile, or alternatively display their information with the function author_profile().

Usage:

<?php get_author_profile(auth_ID); ?>

Usage notes: To get information on more than one user profile, simply run get_author_profile() again with another user ID to reset the author variables (but only after you’re done with the previous profile info!). get_author_profile() is “author template aware,” so if you drop it in a theme’s author.php without providing a user ID, it will set the user variables to the ‘current’ user.

Parameter:

auth_ID
(integer) Numeric user ID of a specific author. This is the “ID” number found under the Users administration page. This then enables the following global variables:

  • $author_aim (AOL Instant Messenger ID)
  • $author_displayname (display format selected under Users > Profile)
  • $author_email
  • $author_firstname
  • $author_icq (ICQ number)
  • $author_jabber (Jabber/Google Instant Messenger ID - WP 2.0 only)
  • $author_lastname
  • $author_level
  • $author_login
  • $author_msn (Microsoft Instant Messenger ID)
  • $author_nicename (login in url encoded format)
  • $author_nickname
  • $author_posts (post count)
  • $author_posts_link (URL to all posts)
  • $author_profile (Profile/”About yourself”)
  • $author_url (”Website”)
  • $author_yim (Yahoo Instant Messenger ID)

Also in the mix is the following template tag:

<?php author_profile('authcase', display); ?>

You can use this after get_author_profile() has been called in your template to display various author profile elements without having to echo the variables. The ‘authcase’ (first) parameter accepts:

authcase
(string) Type of infomation to display. Valid values duplicate variables from above:

  • 'aim'
  • 'displayname'
  • 'email'
  • 'firstname'
  • 'icq'
  • 'jabber'
  • 'lastname'
  • 'level'
  • 'login'
  • 'msn'
  • 'nicename'
  • 'nickname' (Default)
  • 'posts'
  • 'posts_link'
  • 'profile'
  • 'url'
  • 'yim'

The display (second) parameter takes either TRUE (display or echo the value) or FALSE (return the value for use in other PHP code). Defaults to TRUE.

Example:

<?php get_author_profile(1); ?>
<div class="profile">
<ul>
<li id="myprofile">Blog Owner:
<ul>
<li><?php author_profile('firstname'); ?> <?php author_profile('lastname'); ?></li>
<li>Jabber: <?php author_profile('jabber'); ?></li>
<li>AIM: <?php author_profile('aim'); ?></li>
<li>Notes: <?php author_profile('profile'); ?></li>
</ul>
</li>
</ul>
</div>

Update [Jul-09-2005] 0.3 Fixes problems with the plugin in WordPress 1.5. This version is also author template aware, meaning you can use get_author_profile() in an author.php theme template without an user ID, and it will set the author variables dynamically for the ‘current’ author. This is now a WordPress 1.5+ plugin. For WordPress 1.2 users, version 0.2 is here.

Update [Jul-11-2005] 0.4 adds a new parameter to author_profile(): display. Information above edited to reflect that. Not sure why I left something like that out originally…

Update [Jan-08-2006] 0.5 represents changes to run under WordPress 2.0 (should still work in 1.5.x). Only thing notably new (outside code changes and additions) are three variables: $author_jabber (author_profile(’jabber’)), $author_nicename (author_profile(’nicename’)) and $author_displayname author_profile(’displayname’)). $author_displayname is the name format users select under “How to display name” on the Users control panel. A few profile elements were removed in WordPress 2.0, these being the MSN IM and ICQ fields. However, if you upgraded from a previous version of WordPress these will be retained in your users’ data (technically, in the new usermeta table).

Update [Jan-12-2006] 0.5.1 - Bug fix to get_author_profile() when no author is passed as an argument (i.e. author queries).

Share and Enjoy:
  • Digg
  • Facebook
  • LinkedIn
  • NewsVine
  • Technorati
  • Sphinn
  • del.icio.us
  • Mixx
  • Google
  • StumbleUpon
  • Live
  • Print this article!
  • feedmelinks
  • E-mail this story to a friend!
  • Reddit

Email will not be published

Website example

Your Comment: