# LifterLMS: Email the Admin About New Enrollments

> Emails you when a student is enrolled in a LifterLMS course, so you can welcome them personally or keep an eye on sales.

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

## Code

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

add_action( 'llms_user_enrolled_in_course', function ( $user_id, $course_id ) {
    $user = get_userdata( $user_id );

    if ( ! $user ) {
        return;
    }

    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

Fires for every enrollment trigger: purchases, memberships, vouchers and manual enrollments.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "LifterLMS: Email the Admin About New Enrollments" 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/
