LifterLMS: Courses Column in the Users List
Adds a "Courses" column to the Users screen showing how many LifterLMS courses each user is enrolled in.
Opens WPIDE on
Code
if ( ! function_exists( 'llms_get_student' ) ) {
return;
}
add_filter( 'manage_users_columns', function ( $columns ) {
$columns['wpide_llms_courses'] = 'Courses';
return $columns;
} );
add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
if ( 'wpide_llms_courses' !== $column ) {
return $output;
}
$student = llms_get_student( $user_id );
$courses = $student ? $student->get_courses( array( 'limit' => 1 ) ) : array();
$found = (int) ( $courses['found'] ?? 0 );
if ( ! $found ) {
return '—';
}
return sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( admin_url( 'admin.php?page=llms-reporting&tab=students&student_id=' . (int) $user_id ) ),
esc_html( sprintf( _n( '%d course', '%d courses', $found ), $found ) )
);
}, 10, 3 );
Notes
Links to the student's LifterLMS reporting page for details.
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.