# Tutor LMS: Admin Alert for Every New Course Enrollment

> Emails the site admin each time a student enrolls in a Tutor LMS course, with the student's name and the course title.

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

## Code

```php
if ( ! function_exists( 'tutor_utils' ) ) {
    return;
}

$wpide_tutor_enroll_courses = array();

add_action( 'tutor_after_enrolled', function ( $course_id, $user_id ) use ( $wpide_tutor_enroll_courses ) {
    if ( $wpide_tutor_enroll_courses && ! in_array( (int) $course_id, $wpide_tutor_enroll_courses, true ) ) {
        return;
    }

    $user = get_userdata( $user_id );

    if ( $user ) {
        wp_mail(
            get_option( 'admin_email' ),
            sprintf( 'New enrollment: %s', get_the_title( $course_id ) ),
            sprintf( "%s (%s) enrolled in \"%s\".", $user->display_name, $user->user_email, get_the_title( $course_id ) )
        );
    }
}, 10, 2 );
```

## Notes

Limit it to some courses with $wpide_tutor_enroll_courses.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tutor LMS: Admin Alert for Every New Course 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/
