How to: List latest registered users

November 15, 2008 at 9:40 am

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>
$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>";