# Tutor LMS: Enroll in the Next Course After Completing One

> Builds a learning path by enrolling students in the next Tutor LMS course automatically when they complete the previous one.

- Type: PHP
- Runs: Run everywhere
- Category: [Courses & Community](https://wpide.com/library/category/learning/)
- Tags: tutor, enrollment, courses
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/tutor-course-sequence-enrollment/

## Code

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

// Completed course ID => next course IDs.
$wpide_tutor_next_courses = array(
    101 => array( 102 ),
);

add_action( 'tutor_course_complete_after', function ( $course_id, $user_id = 0 ) use ( $wpide_tutor_next_courses ) {
    $user_id = $user_id ? (int) $user_id : get_current_user_id();

    foreach ( $wpide_tutor_next_courses[ (int) $course_id ] ?? array() as $next ) {
        if ( $user_id && get_post_type( $next ) === tutor()->course_post_type && ! tutor_utils()->is_enrolled( $next, $user_id ) ) {
            tutor_utils()->do_enroll( (int) $next, 0, $user_id );
        }
    }
}, 10, 2 );
```

## Notes

Best used with free follow-up courses.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutor LMS: Enroll in the Next Course After Completing One" 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/
