# Tutor LMS: CSS Classes Based on the Student's Course Status

> Adds body classes such as wpide-tutor-enrolled or wpide-tutor-completed on Tutor LMS course pages, so you can show or hide elements with CSS.

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

## Code

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

add_filter( 'body_class', function ( $classes ) {
    if ( ! is_singular( tutor()->course_post_type ) ) {
        return $classes;
    }

    $course_id = get_queried_object_id();
    $user_id   = get_current_user_id();

    if ( ! $user_id ) {
        $classes[] = 'wpide-tutor-guest';
    } elseif ( ! tutor_utils()->is_enrolled( $course_id, $user_id ) ) {
        $classes[] = 'wpide-tutor-not-enrolled';
    } else {
        $classes[] = 'wpide-tutor-enrolled';

        if ( tutor_utils()->is_completed_course( $course_id, $user_id ) ) {
            $classes[] = 'wpide-tutor-completed';
        }
    }

    return $classes;
} );
```

## Notes

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

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutor LMS: CSS Classes Based on the Student's Course 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/
