How to: List latest registered users

If you allow user registration on your blog, listing your latest users along with their url could be a good thing to get more users. There’s no WordPress function to do that, but I got the solution :)

Just paste the following code anywhere on your template. It will list your 5 latest registered users. If you want to get more or less users, simply change the 5 in the SQL query.

<h2>Latest registered users</h2>
<ul>
<?php
$usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5");

foreach ($usernames as $username) {
    echo '<li><a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";
}
?>
</ul>

5 Responses

Dec 04 2008 03:38

Been trying to show ‘displayname’ instead of ‘nicename’. Because it seems to be showing up as usernames. Suggestions?

Thanks! Love the site, just what the internet needed.
Mic

May 28 2010 13:29

Hy how i can display this on another page…. please help me

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required