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

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

## Code

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

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutor LMS: Send a Start-Learning Email to New Students" 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/
