# LifterLMS: Body Classes for Enrollment Status

> Adds body classes such as wpide-llms-enrolled or wpide-llms-completed on course and lesson pages so you can tailor the design for each student.

- Type: PHP
- Runs: Frontend only
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: lifterlms, css, body-class
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/lifterlms-course-status-body-class/

## Code

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

add_filter( 'body_class', function ( $classes ) {
    if ( ! is_singular( array( 'course', 'lesson' ) ) ) {
        return $classes;
    }

    $post_id   = get_queried_object_id();
    $course_id = 'lesson' === get_post_type( $post_id ) ? (int) get_post_meta( $post_id, '_llms_parent_course', true ) : $post_id;
    $student   = llms_get_student();

    if ( ! $student ) {
        $classes[] = 'wpide-llms-guest';
    } elseif ( ! $course_id || ! $student->is_enrolled( $course_id ) ) {
        $classes[] = 'wpide-llms-not-enrolled';
    } else {
        $classes[] = 'wpide-llms-enrolled';

        if ( $student->is_complete( $course_id, 'course' ) ) {
            $classes[] = 'wpide-llms-completed';
        }
    }

    return $classes;
} );
```

## Notes

Classes: wpide-llms-guest, wpide-llms-not-enrolled, wpide-llms-enrolled, wpide-llms-completed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LifterLMS: Body Classes for Enrollment Status" 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/
