# LifterLMS: Students Column on the Courses Screen

> Adds a "Students" column to the LifterLMS Courses list showing how many students are currently enrolled, cached for speed.

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

## Code

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

add_filter( 'manage_course_posts_columns', function ( $columns ) {
    $columns['wpide_llms_students'] = 'Students';

    return $columns;
} );

add_action( 'manage_course_posts_custom_column', function ( $column, $course_id ) {
    if ( 'wpide_llms_students' !== $column ) {
        return;
    }

    $key   = 'wpide_llms_students_' . $course_id;
    $count = get_transient( $key );

    if ( false === $count ) {
        $count = count( (array) llms_get_enrolled_students( $course_id, 'enrolled', 10000, 0 ) );
        set_transient( $key, $count, 6 * HOUR_IN_SECONDS );
    }

    echo esc_html( number_format_i18n( (int) $count ) );
}, 10, 2 );

$wpide_llms_flush_students = function ( $user_id, $course_id ) {
    delete_transient( 'wpide_llms_students_' . (int) $course_id );
};
add_action( 'llms_user_enrolled_in_course', $wpide_llms_flush_students, 10, 2 );
add_action( 'llms_user_removed_from_course', $wpide_llms_flush_students, 10, 2 );
```

## Notes

Counts refresh every 6 hours and whenever someone enrolls or is removed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LifterLMS: Students Column on the Courses Screen" 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/
