Tutor LMS: Enrolled Courses Column in Users
Adds a "Courses" column to the Users screen showing how many Tutor LMS courses each user is enrolled in.
Opens WPIDE on
Code
if ( ! function_exists( 'tutor_utils' ) ) {
return;
}
add_filter( 'manage_users_columns', function ( $columns ) {
$columns['wpide_tutor_courses'] = 'Courses';
return $columns;
} );
add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
if ( 'wpide_tutor_courses' !== $column ) {
return $output;
}
$ids = (array) tutor_utils()->get_enrolled_courses_ids_by_user( $user_id );
return $ids ? esc_html( number_format_i18n( count( $ids ) ) ) : '—';
}, 10, 3 );
Notes
Uses Tutor's own enrollment records.
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.