Are you looking for a way to display the latest 5 registered members? While there’s probably a plugin for this, we have created a quick code snippet that you can use to list last five registered users in WordPress.
Instructions:
All you have to do is add this code to your theme’s index.php file:
<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>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 43 best photography themes for WordPress and how to create a donation form in WordPress.
This
is a marvelous idea. However, can you give a brief overview as to how I would
place this into a widget area?
[…] This post was mentioned on Twitter by HN Firehose and wp_freak, WPSNIPP. WPSNIPP said: #wordpress List last five registered users http://bit.ly/hIBhfm #blog please RT 🙂 […]
WordPress list last five registered users…
Place this code in your WordPress theme to display the last five registered users….