Title: Course shortcode classes
Last modified: September 22, 2021

---

# Course shortcode classes

 *  Resolved [Orange](https://wordpress.org/support/users/leegrant/)
 * (@leegrant)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/course-shortcode-classes/)
 * Hi guys,
 * I’m using the [sensei_courses] shortcode to list all course, and am using the
   classes to add a badge to each course, “started”, “completed”, “No started” as
   a UI enhancement for users.
 * The completed works quite well as the list adds a “user-status-completed” class.
   But course which have and haven’t been started both use “user-status-active”.
 * Is there a hook to add a class to courses which haven’t been started as yet?
 * Regards

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Cena (a11n)](https://wordpress.org/support/users/cena/)
 * (@cena)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/course-shortcode-classes/#post-14901955)
 * Hi [@leegrant](https://wordpress.org/support/users/leegrant/) ,
 * > Is there a hook to add a class to courses which haven’t been started as yet?
 * You might take a look at `sensei_has_user_started_course`, seen here:
 * [https://docs.woocommerce.com/sensei-apidocs/function-sensei_has_user_started_course.html](https://docs.woocommerce.com/sensei-apidocs/function-sensei_has_user_started_course.html)
 * That said, we can’t provide support for custom code, but hopefully that will 
   get you pointed in the right direction.
 * Best,
 *  Thread Starter [Orange](https://wordpress.org/support/users/leegrant/)
 * (@leegrant)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/course-shortcode-classes/#post-14905062)
 * Thank you Cena,
 * For anybody who might need this:
 *     ```
       function sensei_lesson_classes( $classes, $class, $course_id ) {
   
       	$user_id = get_current_user_id();
       	if ( 'course' == get_post_type( $course_id ) && is_user_logged_in() ) {
   
       		if ( Sensei_Course::is_user_enrolled( $course_id, get_current_user_id() ) ) {
       			$classes[] = 'started-course';
       		}
       	}
   
       	return $classes;
   
       }
   
       add_filter( 'post_class', 'sensei_lesson_classes', 20, 3 );
       ```
   
    -  This reply was modified 4 years, 8 months ago by [Orange](https://wordpress.org/support/users/leegrant/).
 *  [Cena (a11n)](https://wordpress.org/support/users/cena/)
 * (@cena)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/course-shortcode-classes/#post-14908266)
 * Hi [@leegrant](https://wordpress.org/support/users/leegrant/) ,
 * Thank you for the snippet!
 *  Looking at your original question again, it looks like I misread your intent.
   My apologies! Glad you got it figured out anyway. 🙂
 * Best,
    Cena

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Course shortcode classes’ is closed to new replies.

 * ![](https://ps.w.org/sensei-lms/assets/icon-128x128.gif?rev=2914239)
 * [Sensei LMS - Online Courses, Quizzes, & Learning](https://wordpress.org/plugins/sensei-lms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sensei-lms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sensei-lms/)
 * [Active Topics](https://wordpress.org/support/plugin/sensei-lms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sensei-lms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sensei-lms/reviews/)

## Tags

 * [customization](https://wordpress.org/support/topic-tag/customization/)

 * 3 replies
 * 2 participants
 * Last reply from: [Cena (a11n)](https://wordpress.org/support/users/cena/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/course-shortcode-classes/#post-14908266)
 * Status: resolved