Tuesday, December 1, 2020
Home Blogging How to Display Recently Registered Users in WordPress

How to Display Recently Registered Users in WordPress

For multi-user WordPress websites, it’s possible you’ll wish to showcase your users on totally different sections of your web site. For instance, you’ll be able to showlisting of authors with avatars, or add an writer information field, and so on. On this tutorial we’ll present you find out how to show just lately registered users in WordPress. These users don’t must be authors. It may be used for a group web site that permits for person registration.

Very first thing you have to do is copy and paste the next code in your theme’s features.php file or in a site-specific plugin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function wpb_recently_registered_users() {
global $wpdb;
$recentusers = '<ul class="recently-user">';
$usernames = $wpdb->get_results("SELECT user_nicename, user_url, user_email FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
foreach ($usernames as $username) {
if (!$username->user_url) :
$recentusers .= '<li>' .get_avatar($username->user_email, 45) .$username->user_nicename."</a></li>";
else :
$recentusers .= '<li>' .get_avatar($username->user_email, 45).'<a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";
endif;
}
$recentusers .= '</ul>';
return $recentusers
}

Now you’ll be able to show the users in your web site by utilizing the next template tag in your theme’s template file reminiscent of sidebar.php, footer.php and so on:

1
<?php wpb_recently_registered_users(); ?>

If you wish to show newly registered users on a selected web page with out making a web page template, then you should utilize a shortcode.

You May Also Like : How to Set Default Admin Color Scheme for New Users in WordPress

Merely add this code in your theme’s features.php file or the site-specific plugin, just under the code you entered earlier.

1
add_shortcode('wpb_newusers', 'wpb_recently_registered_users');

This code will create a brand new shortcode so that you can use in your posts, pages, or widgets. Use it like this:

[wpb_newusers]

We hope this text helped you show just lately registered users in WordPress. For suggestions and questions, please depart a remark.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

How to make money with Toluna surveys

Toluna is most well-known for its surveys, however there are an entire host of different methods to earn rewards on the location. Our assessment...

6 Best Free Alternatives To Camtasia 2020 For Mac And Windows

I really like Camtasia and have been an avid person of Camtasia ever since 2012. Recently, the Camtasia workforce launched the 2019 model of Camtasia which...

List of Travel Affiliate Programs For Travel Bloggers

For me, touring is freedom. If you're a journey blogger, I offer you a standing ovation. Being a digital nomad, I perceive how powerful it's to weblog whereas touring. I additionally...

Social Warfare Review: Explode your Social Shares

Everybody is aware of that having social media sharing buttons is important for each weblog within the Blogosphere. Why? Well, social media sharing buttons assist us...

Recent Comments