LifterLMS: Learning Path With Automatic Next-Course Enrollment
Creates a learning path by enrolling students in the next LifterLMS course automatically when they finish the previous one.
Opens WPIDE on
Code
if ( ! function_exists( 'llms_enroll_student' ) ) {
return;
}
// Completed course ID => next course IDs.
$wpide_llms_next_courses = array(
101 => array( 102 ),
);
add_action( 'lifterlms_course_completed', function ( $user_id, $course_id ) use ( $wpide_llms_next_courses ) {
foreach ( $wpide_llms_next_courses[ (int) $course_id ] ?? array() as $next ) {
if ( 'course' === get_post_type( $next ) && ! llms_is_user_enrolled( $user_id, $next ) ) {
llms_enroll_student( (int) $user_id, (int) $next, 'wpide_sequence' );
}
}
}, 10, 2 );
Notes
Map each completed course to the course(s) that should follow.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.