Whenever you search for anything on google, you will see that there’s a statement – “You visited this page on DD/MM/YYYY” above the search results. Google gives you this option to know when you visited a website the last time. Similarly, you can add the user’s last login date on your website to know the exact date and time they were logged in to your website.
Adding this option has some obvious advantages, such as keeping track of when users come to your website and knowing the active user base. In some cases, users request this feature for their own use. Anyways, it is always better to have more data on our side, right?
Alright. Now, you are all set to show a user’s last login date in WordPress. So how will you do it?
This article will simply answer your question and help you show a user’s last login date in WordPress. And you will be amazed at how easy this process is at the end of the article.
So let’s start reading.
Why You Should Know the User’s Last Login Date?
Many websites nowadays have enabled the last login date option on their website. Displaying the last login date is not only an aesthetic enhancement to the WordPress website, but it also offers certain advantages, like,
- Security – By knowing the user’s last login date, you can detect when someone used your credentials and take appropriate action. It acts as a security measure to prevent any suspicious activity on your site.
- Remove inactive users – You can remove inactive users based on their last login date. This helps to keep a check on the users and keep those who are participating and interacting with your site on a daily basis.
- Site performance – This can be used as a metric to evaluate your site’s performance. When there are more users whose last login date is in recent time, it means your site is getting more engagement and traffic.
How to Show User’s Last Login Date
Showing the user’s last login date is a simple procedure that can be done with the help of plugins, or you can do it manually using code snippets. Throughout this article, we will walk you through both steps step-by-step.
First, we’ll let you know the two methods we’re going to cover in this article. These two methods are;
- Showing User’s Last Login Date by Manually Editing Code
- Showing User’s Last Login Date Using WordPress Plugin
Now, let’s get started…
1. Showing the User’s Last Login Date by Manually Editing Code
Coding is the best way to make changes to your WordPress website when you don’t want any third-party involvement in your site. Besides, if you are good at coding, you can literally make all the changes you need on your website using codes.
You can insert the code snippet to your website either from the cPanel provided by your web host or from the functions.php file in your theme file editor. We are using the method of inserting code in your theme file editor.
First of all, to access the function.php file, Click on Dashboard -> Tools -> Theme file editor. It will take you to the edit themes page.
Click on the Theme Functions (functions.php) option and insert the below code to show the user’s last seen on your WordPress site. Make sure you do not make any changes to the codes that are already in the file.
Here’s the code snippet:
Enter the code and click on the update file and save the changes.
Now go to the Users-> Add users. You can see that the user’s last login is now appearing in the user section.
2. Showing the User’s Last Login Date Using WordPress Plugin
Using plugins is the simplest solution to every problem you face with a WordPress website. Because there are no technicalities involved when you are using a plugin, anyone can install and use it within seconds.
Using a plugin to display the user’s last login date may sound like a good idea, but which plugin is the best? Here’s the answer. We suggest you go with the plugin “When Last Login” which has over 20,000+ installations and great user reviews.
Let us see the step-by-step process to install and use the plugin.
As usual, choose the plugin option from your dashboard and click on “Add new.”
On the plugin search bar, type “When Last Login”. In the following series of search results, you can find our desired plugin at the top of the search results. Click on “Install now” and press “Activate” to activate the plugin. Now the plugin has been connected and activated on your WordPress website.
Follow the steps below to view your WordPress website’s last user login.
From your Dashboard, Go to Users -> All users. This will show you the list of users who have logged in to your site.
In the user’s section, you can see the last login of each user displayed on the right side of the screen, straight to their names.
It is as simple as that.
Alternate Plugins for Showing User’s Last Login Details
Although “When Last Login” is a great plugin, but you may still want to have some options to choose from.
So we are providing you with an alternate plugin that you can use for this purpose.
The best alternate plugin that we can provide you with is the “WP Last Login” plugin. This plugin has more than 10,000+ installations and has an average rating of 4.5 stars from users.
Once activated and installed on your WordPress site, this plugin works similarly to the last login plugin. Additionally, this plugin has a special feature that lets you sort out users on the basis of their last login date. This feature is helpful when removing inactive users from your WordPress site.
Frequently Asked Questions (FAQs)
We always try to cover every question that comes to the reader’s mind and answer them in the best possible manner. Likewise, these are the 3 most commonly asked questions by readers regarding this particular problem.
Q1. Do the plugins or the code record each time the user logs in or updates the existing data?
Both methods update the existing data with the new time once the user logs in to the site. Creating a new record every time a new user logs in to an account will create unnecessary data hoarding.
Q2. How does adding users’ login details help the website’s security?
When you add a user’s last login details, you can keep track of the user’s activity. So when someone suspiciously logs in from your account, the user can find it easily by checking their last login details and taking necessary measures.
Q3. What is the best way to add a user’s last login details in WordPress?
The two methods we discussed in the article – using codes and plugins- are equally the best methods to add a user’s last login details in WordPress. It is up to your preference as to what method you want to use.
Showing the user’s last login date is a thing of convenience and also a matter of security. In some cases, users will specifically ask the site owners to make an option to show their last login dates. In such cases, addressing the user’s queries and solving their issues is more than necessary.
I hope this article helped you easily show the user’s last login date in WordPress. In case you have any doubts regarding the same,
please leave a comment and share this article with your friends and family who might need a helping hand!