How to Display Users' Last Login Date/Time in WordPress (Step by Step)

Last updated: 10-18-2020

Read original article here

How to Display Users' Last Login Date/Time in WordPress (Step by Step)

If you’re looking to display users’ last login date/time on your WordPress website, you’ve come to the right place.

Adding a user activity box on your WordPress website is straightforward. The key thing to remember is that WordPress itself doesn’t provide any kind of information about when a user logged in to your site.

However, there are still a few legit ways to show a user’s last login date/time on your WordPress website.

When we have a multi admin/author or a WordPress membership website, we sometimes need to track the activity of numerous WordPress users to stay updated.

To help you track users’ activity, we have created a step-by-step guide to display your users’ last login date/time in WordPress.

There are two simple ways to show users’ last login details on your WordPress site:

In this method, we’ll use a third-party plugin, When Last Login, to show users’ last login on WordPress.

When Last Login is a lightweight plugin, it enables you to see all active users according to their most recent login time/date.

The best thing about this plugin is that there is no complex configuration, all you need to do is install and activate the plugin, and you’re ready to go.

Once you enable the plugin, it will add a custom column to your WordPress users list with a “Last Login” option and a timestamp linked to particular users.

Let’s check the key features of this plugin:

That’s a brief overview of When Last Login plugin. Let’s dive into details of how to use it to display users’ last login dates in WordPress.

The first step is to install and activate the plugin on your WordPress website. To install the plugin, navigate to your WordPress dashboard Plugins >> Add New and then search “When Last Login“.

Once you’re able to locate the plugin, click on the “Install Now” button. After the installation of the plugin, make sure you activate it right away.

After the installation and the activation of the plugin, you will be able to see the When Last Login menu on the left sidebar of your WordPress dashboard. Navigate to your WordPress website and then When Last Login >> Settings.

On the settings page of the plugin, you will see various options:

Record Users’ IP Address: If you enable this feature, the plugin will automatically record the IP address of users who log in to your WordPress website. Don’t worry; the plugin anonymizes the IP address to support the GDPR guidelines.

Enable “All Login Record”: If you enable these options, the plugin will automatically enable all login records of your WordPress website quickly and easily.

In the Tools section, you will find various options such as Clear Old Logs, Clear All Logs, and Clear All IP Addresses. You can make changes as required.

Once you’re done making all the changes, don’t forget to click on the “Save Settings” to make the settings go live.

That’s all you need to do to show your last login users’ date on your WordPress website using a third-party plugin. To check whether the feature is working or not, navigate to your WordPress website Users >> All Users.

You will now see a “Last Login” column that will show your website users’ last login date in a clean interface.

This method will edit WordPress files to show users’ last login date by editing the WordPress function .php file.

Note: If you have little to no knowledge of coding, we highly recommend you to follow the first method listed above to display the last login dates in WordPress.

For this particular method, we’re going to use the cPanel provided by your website hosting provider. If you don’t have cPanel access, you can also edit the functions.php file using an FTP program.

Login to your website cPanel; once you’re there, navigate to File Manage option. If you want to find the themes’ functions.php file, you need to click on the public_html directory; this will be located in the root folder.

After that, you need to click on the wp-content folder. In this area, you will find all your WordPress website files; click on the themes folder.

Now you need to find the theme folder you’re currently using on your WordPress website. We would suggest you to use a child theme for this purpose, as that’s more safe and secure.

Now you need to right-click on the functions.php file and then click on the “Edit” button. Here you can also click the “edit” option from the cPanels’ top toolbar.

After that, you need to copy and paste the following code right into the functions.php file:

Once you’re done adding the post, click on the “Save Changes” button.

In this step, you need to display the last login notification. To do this, you need to add the listed shortcode where you want the notification to appear.

You can copy and paste the above shortcode in your WordPress posts and widgets to display users’ login time/date in WordPress.

And this is how you can successfully add users’ last login time in WordPress manually. We highly recommend you use a child theme to make the changes listed above.

That was our step-by-step walkthrough to help you show users’ last login time/dates on your WordPress website.

You can display any user’s last login time/dates using a third-party plugin method, or you can manually display the last login dates/time of users on WordPress.

If you’re a beginner with little to no coding knowledge, we recommended you following the plugin method to show users’ last login time/dates on WordPress.

Manually displaying users’ login dates/time is a bit tricky and needs some technical and coding knowledge.

Which method would you follow to display the last login on your WordPress website? Feel free to share your thoughts in the comments section below.

If this post has been helpful to you, you can share it on social media channels such as Facebook, LinkedIn, and Twitter.

Read the rest of this article here