LifterLMS: Last Lesson Completed Column in Users
Records when each student last completed a LifterLMS lesson and shows it in a "Last lesson" column on the Users screen, to spot students who have stalled.
Opens WPIDE on
Code
if ( ! function_exists( 'llms_get_student' ) ) {
return;
}
add_action( 'lifterlms_lesson_completed', function ( $user_id ) {
update_user_meta( (int) $user_id, 'wpide_llms_last_lesson', time() );
} );
add_filter( 'manage_users_columns', function ( $columns ) {
$columns['wpide_llms_last'] = 'Last lesson';
return $columns;
} );
add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
if ( 'wpide_llms_last' !== $column ) {
return $output;
}
$time = (int) get_user_meta( $user_id, 'wpide_llms_last_lesson', true );
return $time ? esc_html( sprintf( '%s ago', human_time_diff( $time ) ) ) : '—';
}, 10, 3 );
Notes
Activity is tracked from activation onwards.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.