Family Encyclopedia >> Electronics

How to show recently registered users in WordPress

For multi-user WordPress sites, you may want to display your users in different sections of your website. For example, you can display a list of authors with avatars, or add an author info box, etc. In this tutorial we will show you how to display recently registered users in WordPress. These users do not need to be authors. It can be used for a community site that allows user registration..

The first thing you need to do is copy and paste the following code into your theme funciones.php file or in a site-specific plugin.

 función wpb_recently_registered_users () global $ wpdb; $ recentusers = '
    '; $ nombres de usuario = $ wpdb-> get_results ("SELECT user_nicename, user_url, user_email DESDE $ wpdb-> usuarios ORDER BY ID DESC LIMIT 5"); foreach ($ usernames como $ username) si (! $ username-> user_url): $ recentusers. = '
  • '.get_avatar ($ username-> user_email, 45). $ username-> user_nicename. "
  • "; else: $ recentusers. = '
  • '.get_avatar ($ username-> user_email, 45).' user_url. '">'. $ username-> user_nicename."
  • "; endif; $ recentusers. = '
'; return $ recentusers;

You can now display users on your site using the following template tag in your theme's template file, like sidebar.php, footer.php, etc.

 

If you want to display newly registered users on a specific page without creating a page template, you can use a shortcode.

Simply add this code to your theme's functions.php file or site-specific plugin, right below the code you entered earlier.

 add_shortcode ('wpb_newusers', 'wpb_recently_registered_users'); 

This code will create a new shortcode for you to use in your posts, pages, or widgets. Use it like this:

[wpb_newusers]

We hope this article has helped you display recently logged in WordPress users. For comments and questions, please leave a comment.