Support » Plugin: Sensei LMS - Online Courses, Quizzes, & Learning » Course shortcode classes

  • Resolved Orange

    (@leegrant)


    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)
  • Plugin Support Cena (a11n)

    (@cena)

    Hi @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

    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

    (@leegrant)

    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 7 months, 3 weeks ago by Orange.
    Plugin Support Cena (a11n)

    (@cena)

    Hi @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.