How to Save and Show Last Login Date and Time of Users in WordPress

At times, you may need the functionality of showing last login date and time of users on WordPress Dashboard. As WordPress provide functions to get and set last login date and time, so you can easily save user’s last login date and time.

To achieve this functionality, you can use the following code in your Theme‘s functions.php file:

Additionally, you can display current login date/time and the last login date/time by using the following code:

Note: Just by adding true in pt_get_last_login($current_user->ID, true)), you can show the previous login date to your users.

In case if you want to display days since last login as compared to the current login date, use the following code:

User Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

    Get in Touch