# Tutor LMS: Track Each Student's Most Recent Lesson in Users

> Records when each student last completed a Tutor LMS lesson and shows it in a "Last lesson" column on the Users screen.

- Type: PHP
- Runs: Run everywhere
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: tutor, users, reporting
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/tutor-last-lesson-users-column/

## Code

```php
if ( ! function_exists( 'tutor_utils' ) ) {
    return;
}

add_action( 'tutor_lesson_completed_after', function ( $lesson_id, $user_id = 0 ) {
    $user_id = $user_id ? (int) $user_id : get_current_user_id();

    if ( $user_id ) {
        update_user_meta( $user_id, 'wpide_tutor_last_lesson', time() );
    }
}, 10, 2 );

add_filter( 'manage_users_columns', function ( $columns ) {
    $columns['wpide_tutor_last'] = 'Last lesson';

    return $columns;
} );

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

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

    return $time ? esc_html( sprintf( '%s ago', human_time_diff( $time ) ) ) : '&mdash;';
}, 10, 3 );
```

## Notes

Tracking starts when the snippet is activated.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutor LMS: Track Each Student's Most Recent Lesson in Users" 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/
