# 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.

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

## Code

```php
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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LifterLMS: Personal Welcome Email on Enrollment" 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/
