In WordPress, you can see who is currently logged in to the website by using a plugin or by writing custom code. Here are the steps to see who is logged in:
- Install and activate the “User Activity Log” plugin from the WordPress plugin repository.
- Once activated, go to the “Reports” tab in the WordPress dashboard menu.
- Click on the “User Activity” submenu to see a list of all user activity on the website, including who is currently logged in.
If you prefer to write custom code to see who is logged in, you can do so also.
Get the current user object using the
wp_get_current_user() function and check if the user ID is not equal to 0, which indicates that someone is logged in. Then display a message with the user’s login name using
Add code to a WordPress template file or to a plugin file to display the currently logged-in user on your website.