Tutor LMS: Enroll New Users in Free Courses
Enrolls every newly registered user in the Tutor LMS courses you choose, such as a free getting-started course.
Opens WPIDE on
Code
if ( ! function_exists( 'tutor_utils' ) ) {
return;
}
// Course IDs.
$wpide_tutor_starter_courses = array( 123 );
add_action( 'user_register', function ( $user_id ) use ( $wpide_tutor_starter_courses ) {
foreach ( $wpide_tutor_starter_courses as $course_id ) {
if ( get_post_type( $course_id ) === tutor()->course_post_type && ! tutor_utils()->is_enrolled( $course_id, $user_id ) ) {
tutor_utils()->do_enroll( (int) $course_id, 0, (int) $user_id );
}
}
}, 20 );
Notes
Use free courses here; paid courses should be enrolled through their checkout.
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.