LifterLMS: Personal Welcome Email on Enrollment
Sends students a short, personal welcome email when they are enrolled in a LifterLMS course, with a direct link to start learning.
Opens WPIDE on
Code
if ( ! function_exists( 'llms_get_student' ) ) {
return;
}
$wpide_llms_welcome_courses = array();
add_action( 'llms_user_enrolled_in_course', function ( $user_id, $course_id ) use ( $wpide_llms_welcome_courses ) {
if ( $wpide_llms_welcome_courses && ! in_array( (int) $course_id, $wpide_llms_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 now enrolled in \"%s\". Start whenever you are ready:\n%s\n\nHappy learning!\n%s",
$user->first_name ? $user->first_name : $user->display_name,
get_the_title( $course_id ),
get_permalink( $course_id ),
get_bloginfo( 'name' )
)
);
}, 10, 2 );
Notes
Limit it to some courses with $wpide_llms_welcome_courses; leave it empty for all courses.
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.