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.
Opens WPIDE on
Code
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 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.