# Last Login Column Across the Network

> Records when each user last signed in anywhere on the network and shows it in Network Admin > Users, making inactive accounts easy to find.

- Type: PHP
- Runs: Run everywhere
- Category: [Multisite](https://wpide.com/library/category/multisite/)
- Tags: network-admin, users, login, columns
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/ms-users-last-login-column/

## Code

```php
if ( ! is_multisite() ) {
    return;
}

add_action( 'wp_login', function ( $login, $user ) {
    update_user_meta( $user->ID, 'wpide_network_last_login', time() );
}, 10, 2 );

if ( ! is_admin() ) {
    return;
}

add_filter( 'wpmu_users_columns', function ( $columns ) {
    $columns['wpide_last_login'] = __( 'Last login' );

    return $columns;
} );

add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
    if ( 'wpide_last_login' !== $column ) {
        return $output;
    }

    $time = (int) get_user_meta( $user_id, 'wpide_network_last_login', true );

    if ( ! $time ) {
        return '&mdash;';
    }

    return sprintf(
        '<span title="%1$s">%2$s</span>',
        esc_attr( wp_date( 'Y-m-d H:i', $time ) ),
        /* translators: %s: human time difference */
        esc_html( sprintf( __( '%s ago' ), human_time_diff( $time ) ) )
    );
}, 10, 3 );
```

## Notes

The column fills in as people log in after you activate the snippet; earlier logins are not known.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Last Login Column Across the Network" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
