If you run a WordPress site with multiple users, you’ve probably wondered how to see when someone last logged in. Whether you’re managing a membership site, an online store, or a blog with several authors, tracking user activity can help you spot inactive accounts and strengthen site security.
The only problem is that WordPress doesn’t show this information by default.
The good news is that there are easy ways to add it. After testing several methods, we’ve found two simple and reliable options that won’t slow down your site.
In this guide, we’ll show you how to display the last login date for each user in WordPress step by step.

💡Quick Answer: Display a User’s Last Login in WordPress
There are two main ways to show a user’s last login date in WordPress:
- Use a Plugin: The WP Last Login plugin is the easiest method. It adds a ‘Last Login’ column to your Users screen in the admin area.
- Add Custom Code: A more flexible method is to add a PHP code snippet using the WPCode plugin. This allows you to display the last login date anywhere on your site, like in user profiles.
Why Display the User’s Last Login Date in WordPress?
Tracking when users last logged into your website provides valuable insights for security and administration. Here are the key benefits:
- Manage Multi-Author Sites: If you run a blog with multiple contributors, you can easily see when your authors, editors, and other staff are logging in to work on content.
- Improved Security: By monitoring the last login date, you can quickly spot suspicious activity. For example, if you notice an unusual login time for an admin account, you can investigate immediately. It also helps identify and remove inactive accounts that could become security risks.
- Monitor User Activity: For membership sites, online courses, or forums, seeing the last login date shows you how engaged your users are. This can help you identify users who may need re-engagement campaigns.
There are 2 ways to show the user’s last login date in WordPress.
First, you can use a plugin to show the login date inside the WordPress admin panel. Second, you can manually show the last login date using a custom code snippet.
Simply click the links below to jump ahead to your preferred section:
- Method 1: Showing a User's Last Login Date in WordPress Admin Area
- Method 2: Manually Show User's Last Login Date in WordPress
- Frequently Asked Questions About User Login Dates
Method 1: Showing a User’s Last Login Date in WordPress Admin Area
You can easily show the last login date using the WP Last Login plugin. It is a free plugin designed specifically to add a ‘Last Login’ column to your admin dashboard.
This method is easier, but it will only show a user’s last login date inside the WordPress admin area.
The first thing you need to do is install and activate the WP Last Login plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
The best thing is that the plugin works out of the box, and there are no additional settings you have to worry about.
Upon activation, you need to visit the Users » All Users page in the admin area. You will notice a new column showing each user’s last login date.

At first, it may show ‘never’ for all users. That’s because a user needs to log in since the plugin has been activated, so that it can capture the last login date and store it.
Method 2: Manually Show User’s Last Login Date in WordPress
This method allows you to display a user’s last login date anywhere on your WordPress site.
However, it requires adding custom code to your theme’s functions.php file or a site-specific plugin. We don’t recommend editing the functions.php file directly because the slightest mistake can break your website.
An easier way of adding custom code to your site is by using the WPCode plugin. It is the best code snippet plugin for WordPress that helps manage, organize, and insert custom code anywhere on your site without breaking anything.
Plus, we love its AI code generator that will create custom code for you. To learn more, see our detailed WPCode review.
First, you’ll need to install and activate the WPCode plugin. If you need help, then please see our guide on how to install a WordPress plugin.
Note: There is also a free WPCode plugin that you can use for this tutorial. However, upgrading to the premium plugin will give you access to a cloud-based code snippet library, smart conditional logic, and more.
Upon activation, you can go to Code Snippets » + Add Snippet from the WordPress dashboard.
Next, simply hover over the ‘Add Your Custom Code (New Snippet)’ option and click on ‘Use snippet’.

After that, you can copy the following code and add it to the Code Preview area:
<?php
/**
* Capture user login and add it as timestamp in user meta data
*
*/
function user_last_login( $user_login, $user ) {
update_user_meta( $user->ID, 'last_login', time() );
}
add_action( 'wp_login', 'user_last_login', 10, 2 );
/**
* Display last login time
*
*/
function wpb_lastlogin() {
$last_login = get_the_author_meta('last_login');
$the_login_date = human_time_diff($last_login);
return $the_login_date;
}
/**
* Add Shortcode lastlogin
*
*/
add_shortcode('lastlogin','wpb_lastlogin');
?>
This code adds the last login as a meta key.
Each time a user logs in, it saves the time as a meta key value.
After entering the code, you will also need to enter a title for your custom code and select the ‘Code Type’ as PHP Snippet.

From here, you can scroll down and choose where to insert the code.
For this tutorial, we will use the default method and keep it to the ‘Auto Insert’ method. This way, the custom code will run everywhere on your website.

Once you are done, simply scroll back to the top.
Go ahead and activate your custom code snippet and click the ‘Save Snippet’ button.

If you are new to adding code, then please read this guide on pasting code from the web.
You can now display the last login date value using the [lastlogin] shortcode in your WordPress posts, pages, and widgets.
To use it, simply edit a post or page and add a ‘Shortcode’ block. Inside the block, paste the shortcode:
[lastlogin]

Now, when a logged-in user views the page, they will see their own last login time. If a visitor is logged out, the shortcode will display nothing.
Similarly, if you want to show the last login information in your child theme, then you can add this code instead:
<?php echo 'Last seen: '. do_shortcode('[lastlogin]') .' ago'; ?>
Before you test the plugin, you will need to log out of WordPress and then log in again.
Then, you should visit your WordPress website to see the login date in action.

As you will notice, this code displays the relative date and time, ‘2 hours ago’ instead of the full date and time.
If you want to display the full date and time, then you need to find this line in the code above:
$the_login_date = human_time_diff($last_login);
Now replace it with this line:
$the_login_date = date('M j, Y h:i a', $last_login);
The M j, Y h:i a part in this code is called the date and time format string. If you want to change how this code displays the date and time, then just check out our guide on how to change the date and time format in WordPress.
Frequently Asked Questions About User Login Dates
Here are some questions that our readers frequently ask about displaying user login dates in WordPress:
Why does the ‘Last Login’ column say ‘never’ for all my users?
This is normal behavior right after you activate the plugin or add the code. The system can only track logins that happen after it has been installed.
It does not have access to historical login data. The ‘never’ message will be replaced with the correct date and time for each user the first time they log in again.
How can I show the exact date and time instead of ‘2 hours ago’?
If you used the code snippet in Method 2, you can easily change the format. Find the line in the code that says $the_login_date = human_time_diff($last_login); and replace it with $the_login_date = date('M j, Y h:i a', $last_login);. This will display the full date and time stamp.
Will tracking the last login date slow down my WordPress site?
No, the methods described in this article are very lightweight. Both the plugin and the custom code snippet run a simple function that adds a small entry to your database when a user logs in. This action is efficient and will not have a noticeable impact on your site’s performance.
We hope this article helped you learn how to show a user’s last login date in WordPress. You may also want to see our guide on how to add an author info box in WordPress posts and our tutorial on how to add social login to WordPress.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


Christopher Garret
Thank you, very useful. I appreciate the code, which allows me to customize how to collect this data!
WPBeginner Support
Glad you found it helpful!
Admin
Louise Panvig
Hi is it possible to show a red dot if the user is offline and a green dot if they are online?
WPBeginner Support
That would be a different plugin, for something close to that, we would recommend taking a look at our article below:
https://www.wpbeginner.com/wp-tutorials/how-to-show-real-time-online-users-in-wordpress/
Admin
Babak Fakhamzadeh
It is worth being aware of that Wordfence stores the last login date as a meta field.
WPBeginner Support
Thanks for sharing that current feature for those using Wordfence.
Admin
Fredrick Arije
Thanks for the script.
I have an observation. All users sees the last login of the admin (author).
Is there a way for each user to see their own last login?
Please help. Thanks
WPBeginner Support
For showing individual last logins we would recommend using the plugin method as a manual code method would be more advanced than what we would recommend for beginners.
Admin
Bobby
Hello,
It works great but the time stamp when the line is changed for date/time still shows a 7 hour time difference?
How can I make the last login time show Pacific Standard Time. That is my timezone.
Please advise, thanks.
Cheers!
Nobin
Thanks For Share
That was most useful trick