Tutor LMS: Send a Start-Learning Email to New Students
Sends students a friendly welcome email with a direct "start learning" link as soon as they enroll in a Tutor LMS course.
Opens WPIDE on
Code
if ( ! function_exists( 'tutor_utils' ) ) {
return;
}
$wpide_tutor_welcome_courses = array();
add_action( 'tutor_after_enrolled', function ( $course_id, $user_id ) use ( $wpide_tutor_welcome_courses ) {
if ( $wpide_tutor_welcome_courses && ! in_array( (int) $course_id, $wpide_tutor_welcome_courses, true ) ) {
return;
}
$user = get_userdata( $user_id );
if ( ! $user ) {
return;
}
wp_mail(
$user->user_email,
sprintf( 'Welcome to %s', get_the_title( $course_id ) ),
sprintf(
"Hi %s,\n\nYou are enrolled in \"%s\". Jump in whenever you are ready:\n%s\n\nYour dashboard: %s",
$user->first_name ? $user->first_name : $user->display_name,
get_the_title( $course_id ),
get_permalink( $course_id ),
tutor_utils()->tutor_dashboard_url()
)
);
}, 10, 2 );
Notes
Limit it to some courses with $wpide_tutor_welcome_courses; leave empty for all.
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.