How to Show a User’s Last Login Date in WordPress (3 Ways)

How to Show Last Login Column in WordPress Users List

WordPress doesn’t record when a user last logged in. Open the Users screen and you get the default admin columns (names, emails, roles and post counts), but nothing that tells you whether an editor was here yesterday or hasn’t signed in since last spring.

Below are three ways to add a WordPress last login column to Users > All Users: the option built into WP Adminify’s productivity tools, a free single-purpose plugin, or a short snippet we tested on WordPress 7.1. There’s also a trick for getting login times for anyone who’s signed in right now, before you’ve installed anything, and a quick routine for using the column to find accounts nobody uses.

Quick answer: WordPress doesn’t track last login by default. To show it, enable WP Adminify > Productivity > Custom Admin Columns > Show “Last Login” Column for Users (Pro), install a free plugin like When Last Login or WP Last Login, or add a wp_login hook that saves a timestamp to user meta and displays it with the manage_users_custom_column filter.

Does WordPress Track Last Login by Default?

No. Core has no “last login” field. The wp_users table stores user_registered and that’s it, so every plugin and snippet starts recording on the day you activate it and knows nothing about the time before.

There’s one exception, and most tutorials skip it. Every login creates a session, which WordPress saves in the session_tokens user meta along with a login Unix timestamp, the IP address and the browser’s user agent. Sessions last 2 days, or 14 if the user ticked “Remember Me.” So for anyone logged in right now, WordPress already knows when their session started. Method 3 reads that value to fill in the column for active users on day one.

Where the column earns its place:

  • Dormant admin and editor accounts are an easy target, and you can’t remove access you don’t know is unused. That’s the least-privilege idea behind the WordPress roles and capabilities system.
  • On multi-author sites you can see who’s still writing and who needs a nudge without asking around.
  • On membership and client sites it shows whether people use the accounts you set up for them.

Method 1: Add a Last Login Column with WP Adminify

If you already run WP Adminify, this is a checkbox in the Custom Admin Columns module. It’s a Pro option. The free version shows the checkbox with an “Upgrade to Pro” label next to it. You don’t need any other plugin.

Step 1: Open the Productivity tab

In your dashboard, go to WP Adminify > Settings and click the Productivity tab.

WP Adminify settings page with the Productivity tab selected
The Productivity tab holds the Custom Admin Columns module.

Step 2: Enable the Last Login column

Scroll down to Custom Admin Columns and set the toggle to SHOW. Tick Show “Last Login” Column for Users and click Save Settings. The Post Thumbnails, Post/Page ID and URL Path columns live in the same list if you want them too.

Show Last Login Column for Users checkbox in WP Adminify Custom Admin Columns
The Last Login option in Custom Admin Columns.

Step 3: Check the Users screen

Open Users > All Users and you’ll see a Last Login column on the far right with the date and time of each user’s last sign-in. Anyone who hasn’t logged in since you turned it on shows Never logged in.

WordPress users list with the WP Adminify Last Login column showing the date and Never logged in
WP Adminify’s column uses your site’s date and time format.

What we saw when we checked it on WP Adminify 4.3.2:

  • The date format comes from Settings > General > Date Format and Time Format. Change those and the column changes with them (more in the FAQ).
  • Login times are stored as Unix timestamps in the _adminify_last_login user meta key, which export tools and SQL queries can read.
  • You can’t sort by this column. If sorting matters to you, Method 2 or Method 3 will suit you better.
  • It keeps only the latest login, not a history. For a log of logins, logouts and changes, use the Activity Logs addon.
WordPress Settings General date format and time format options
Date and time formats under Settings > General.

The other columns in this module are covered in the Custom Admin Columns documentation.

Method 2: Use a Dedicated Last Login Plugin

If this column is all you want and you don’t use WP Adminify, a small free plugin gets you there fastest. These are the two Google shows most for “wp last login”:

When Last LoginWP Last Login
Active installs (WordPress.org, Sept 2026)50,000+10,000+
Rating4.7 / 53.7 / 5
Sortable columnYesYes
Display formatRelative (“3 days ago”)Date, exact time on hover
Login historyYes, history tableNo
IP recordingOptionalNo
Multisite network usersNot listedYes

Go to Plugins > Add New, search for When Last Login or WP Last Login, and click Install Now, then Activate. The column shows up on the Users screen straight away, with nothing to configure.

Which one? When Last Login if you want login history and IP data. WP Last Login if you want the lightest thing possible, or you’re on multisite. And if WP Adminify is already handling your other admin columns, the menu editor or white labeling, Method 1 means one less plugin to keep updated.

Method 3: Add a Sortable Last Login Column with Code (No Plugin)

Here’s what the snippet below does:

  1. Saves each login as a UTC timestamp.
  2. Falls back to session_tokens for users who are logged in but have no saved time yet.
  3. Adds the Last Login column.
  4. Shows “3 days ago” with the exact date on hover.
  5. Makes the column sortable without hiding users who have never logged in.

Add it with a snippets plugin (Code Snippets, WPCode, or the Code Snippets tab in WP Adminify), or drop it in wp-content/mu-plugins/last-login.php. Keep it out of your parent theme’s functions.php; the next theme update will wipe it. We ran this exact code on WordPress 7.1 with PHP 8.5.

All Users. */ // 1. Save the login time as a UTC Unix timestamp. function wpa_record_last_login( $user_login, $user ) { update_user_meta( $user->ID, ‘wpa_last_login’, time() ); } add_action( ‘wp_login’, ‘wpa_record_last_login’, 10, 2 ); // 2. Get the last login, falling back to active session data. function wpa_get_last_login( $user_id ) { $last = (int) get_user_meta( $user_id, ‘wpa_last_login’, true ); if ( ! $last ) { $sessions = get_user_meta( $user_id, ‘session_tokens’, true ); if ( is_array( $sessions ) && ! empty( $sessions ) ) { $last = (int) max( wp_list_pluck( $sessions, ‘login’ ) ); } } return $last; } // 3. Register the column. function wpa_add_last_login_column( $columns ) { $columns[‘wpa_last_login’] = __( ‘Last Login’, ‘your-textdomain’ ); return $columns; } add_filter( ‘manage_users_columns’, ‘wpa_add_last_login_column’ ); // 4. Show “3 days ago” with the exact date and time on hover. function wpa_show_last_login_column( $output, $column_name, $user_id ) { if ( ‘wpa_last_login’ !== $column_name ) { return $output; } $last = wpa_get_last_login( $user_id ); if ( ! $last ) { return esc_html__( ‘Never’, ‘your-textdomain’ ); } $exact = wp_date( get_option( ‘date_format’ ) . ‘ ‘ . get_option( ‘time_format’ ), $last ); /* translators: %s: human-readable time difference, e.g. “3 days”. */ $ago = sprintf( __( ‘%s ago’, ‘your-textdomain’ ), human_time_diff( $last ) ); return ‘‘ . esc_html( $ago ) . ‘‘; } add_filter( ‘manage_users_custom_column’, ‘wpa_show_last_login_column’, 10, 3 ); // 5. Make the column sortable without hiding users who never logged in. function wpa_last_login_sortable( $columns ) { $columns[‘wpa_last_login’] = ‘wpa_last_login’; return $columns; } add_filter( ‘manage_users_sortable_columns’, ‘wpa_last_login_sortable’ ); function wpa_last_login_sort_query( $query ) { if ( ! is_admin() || ‘wpa_last_login’ !== $query->get( ‘orderby’ ) ) { return; } $query->set( ‘meta_query’, array( ‘relation’ => ‘OR’, ‘has_login’ => array( ‘key’ => ‘wpa_last_login’, ‘compare’ => ‘EXISTS’, ‘type’ => ‘NUMERIC’, ), ‘no_login’ => array( ‘key’ => ‘wpa_last_login’, ‘compare’ => ‘NOT EXISTS’, ), ) ); $query->set( ‘orderby’, ‘has_login’ ); } add_action( ‘pre_get_users’, ‘wpa_last_login_sort_query’ );
Sortable Last Login column added with code, showing Never and 3 days ago
Sorted by Last Login. The user with no recorded login is still in the list, marked “Never.”

Why this code differs from most tutorials

Most last-login snippets you’ll find, including the one this post used to have, get two things wrong.

  • Sorting hides users. The usual sort code sets meta_key in pre_get_users, which joins the user meta table. Anyone without a saved login falls out of the list the moment you sort, and those are the inactive accounts you were trying to find. The OR meta query above, with one EXISTS clause and one NOT EXISTS clause, keeps them in.
  • Times come out shifted. current_time( 'mysql' ) stores local time, and running that through wp_date() later adds the timezone offset again. On a site set to UTC+6 every time is 6 hours off. Store time() instead and let wp_date() do the conversion once.
Users list sorted with the common last login snippet showing only 1 of 2 users
The common snippet, sorted by Last Login. The user who never logged in is gone: 1 item instead of 2.

Fill in last login for users who are logged in now

When there’s no saved timestamp, wpa_get_last_login() checks session_tokens. Anyone with an active session gets a real date immediately; everyone else shows “Never” until they next log in. The catch is that sorting only looks at saved timestamps, so a user whose date came from a session sorts in with the “Never” group until their next login.

Why a last login can look old

wp_login fires when someone submits the login form. If a user ticked “Remember Me,” they can come back every day for two weeks on the same cookie and never trigger it, so their “last login” doesn’t move. WordPress is working as designed here. It does mean the column is good for spotting inactive accounts and poor as a record of who visited today.

Optional: show last login on the front end

The snippet includes a [last_login] shortcode too. Put [last_login] in a member dashboard to show the current user’s last login, or use [last_login user_id="12"] for a specific person.

// Optional: [last_login] shortcode for the front end. function wpa_last_login_shortcode( $atts ) { $atts = shortcode_atts( array( ‘user_id’ => get_current_user_id() ), $atts, ‘last_login’ ); $user_id = absint( $atts[‘user_id’] ); $last = $user_id ? wpa_get_last_login( $user_id ) : 0; if ( ! $last ) { return esc_html__( ‘Never’, ‘your-textdomain’ ); } return esc_html( wp_date( get_option( ‘date_format’ ) . ‘ ‘ . get_option( ‘time_format’ ), $last ) ); } add_shortcode( ‘last_login’, ‘wpa_last_login_shortcode’ );

How to Find Inactive WordPress Users by Last Login

Give the column a few weeks to collect data, then run through this:

  1. Go to Users > All Users and filter by a role such as Administrator or Editor.
  2. Click the Last Login header to sort oldest first. That works with Method 2 or 3. With WP Adminify you’ll have to scan the column by eye or use the SQL query further down.
  3. Note every account that shows “Never” or a date more than 90 days back.
  4. Decide what to do with each: ask the person, reset the password, drop them to a lower role, or delete the account and reassign its content.

Do the admin accounts first. A forgotten administrator login undoes whatever else you’ve hardened. After that, turn on two-factor authentication for admins and look through WP Adminify’s other security features.

Check Last Login in the Database or with WP-CLI

If you can’t get into the dashboard, or you need a list for a report, you can read the same data directly.

With WP-CLI you can list a user’s active sessions and when each one started. It reads core session data, so no plugin is needed:

# List active sessions for user ID 12 (login time, expiry, IP) wp user session list 12 –fields=login_time,expiration_time,ip # Read the stored last login timestamp wp user meta get 12 _adminify_last_login

With SQL in phpMyAdmin or Adminer, this lists every user by last login, newest first. Swap wp_ for your table prefix, and _adminify_last_login for wpa_last_login if you went with the snippet:

SELECT u.user_login, FROM_UNIXTIME(m.meta_value) AS last_login FROM wp_users u LEFT JOIN wp_usermeta m ON m.user_id = u.ID AND m.meta_key = ‘_adminify_last_login’ ORDER BY m.meta_value DESC;

Skip session_tokens in SQL. It’s a serialized PHP array and painful to query; use WP-CLI or the PHP function above for that.

Which Method Should You Use?

WP Adminify (Pro)Dedicated pluginCode snippet
Setup timeAbout 1 minuteAbout 1 minuteAbout 5 minutes
Code neededNoneNonePHP
Sortable columnNoYesYes
Relative time (“3 days ago”)No, site date formatWhen Last Login: yesYes, exact time on hover
Fills in logged-in users on day oneNoNoYes (session_tokens)
Login historyVia Activity Logs addonWhen Last Login: yesNo
Extra plugin to maintainNo, if you already use WP AdminifyYesNo
Best forSites already running WP AdminifyAnyone who wants just this columnDevelopers and lean setups

WordPress Last Login FAQ

Conclusion

  • WordPress doesn’t store last login dates, so tracking starts the day you add it. Active sessions are the one thing you can fill in after the fact.
  • On WP Adminify Pro it’s a checkbox under Productivity > Custom Admin Columns.
  • When Last Login and WP Last Login are the free picks if you want a sortable column and nothing else.
  • The snippet gets you sorting, “3 days ago” dates and data for logged-in users from day one, without a plugin.

Whichever you choose, sort by last login once a quarter and clear out the accounts nobody uses. If you’d also like a tidier admin menu, white labeling and WP Adminify’s other productivity tools, the last login column comes in the same plugin.


Leave a Reply

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