Tutor LMS Action Hooks: Enrollment, Completion and Orders
Worked examples of the Tutor LMS action hooks for enrollment, lesson and course completion, cancellation and paid orders, with the exact arguments and the order in which they fire.
Checked against the plugin source: Tutor LMS 4.1.3, Tutor LMS Pro 4.1.3

Action hooks let your code run when something happens in Tutor LMS: a student enrolls, finishes a lesson, completes a course, or pays for an order. This guide shows working examples for the hooks that matter most, verified against Tutor LMS 4.1.3. For the full list see the hooks reference.
Where to put the code
Create a small plugin in wp-content/plugins/my-tutor-extensions/my-tutor-extensions.php with a plugin header. Theme functions.php works too, but your code then disappears if the theme changes.
Enrollment: two hooks, two meanings
tutor_after_enroll(course ID, enrollment ID) fires when the enrollment record is created. For a paid course that can be a pending enrollment, before payment.tutor_after_enrolled(course ID, student ID, enrollment ID) fires when an order-based enrollment is completed, through native eCommerce or WooCommerce.
For "the student now has access", check the enrollment status rather than relying on one hook. Enrollments are posts of type tutor_enrolled; access means the post status is completed.
add_action( 'tutor_after_enroll', 'tle_on_enroll', 10, 2 );
function tle_on_enroll( $course_id, $enrollment_id ) {
if ( 'completed' !== get_post_status( $enrollment_id ) ) {
return; // Pending: wait for payment.
}
$user_id = (int) get_post_field( 'post_author', $enrollment_id );
tle_add_to_mailing_list( $user_id, $course_id );
}
add_action( 'tutor_after_enrolled', 'tle_on_paid_enrollment', 10, 3 );
function tle_on_paid_enrollment( $course_id, $student_id, $enrollment_id ) {
tle_add_to_mailing_list( (int) $student_id, (int) $course_id );
}
function tle_add_to_mailing_list( $user_id, $course_id ) {
$user = get_userdata( $user_id );
if ( ! $user ) {
return;
}
// Call your email platform here. Keep it fast or queue it.
}
Make the receiving side idempotent: one enrollment can pass through both hooks.
Lesson completion
tutor_lesson_completed_after passes the lesson ID and user ID. Tutor LMS stores lesson completion in user meta named _tutor_completed_lesson_id_{lesson_id}.
add_action( 'tutor_lesson_completed_after', 'tle_lesson_done', 10, 2 );
function tle_lesson_done( $lesson_id, $user_id ) {
$course_id = tutor_utils()->get_course_id_by( 'lesson', $lesson_id );
update_user_meta( $user_id, 'tle_last_lesson_' . $course_id, $lesson_id );
}
Course completion
tutor_course_complete_after passes the course ID and user ID. Tutor LMS records completion as a comment of type course_completed, and certificates (Pro) follow it.
add_action( 'tutor_course_complete_after', 'tle_course_done', 10, 2 );
function tle_course_done( $course_id, $user_id ) {
$user = get_userdata( $user_id );
if ( $user ) {
$user->add_role( 'graduate' ); // Example: a role you registered yourself.
}
}
Use tutor_course_complete_before (course ID) if you need to act just before the record is written.
Cancellations and deletions
tutor_after_enrollment_cancelledandtutor_after_enrollment_deletedpass the course ID and user ID.tutor/course/enrol_status_change/afterpasses the enrollment ID and the new status when an admin changes it.tutor_enrollment/after/{status}fires per enrollment when statuses are updated in bulk.
Use these to revoke access in other systems, for example a community or a CRM tag.
Paid orders
With native eCommerce, tutor_order_payment_status_changed (order ID, previous status, new status) is the hook for payments and refunds. Tutor LMS uses it at priority 10 to update enrollments, so attach yours at 20. Full example: run code when an order is paid.
Order of events for a paid course
- Checkout creates the order (
tutor_order_placed) and a pending enrollment (tutor_after_enroll). - The gateway confirms payment, and the order changes to paid (
tutor_order_payment_status_changed). - Tutor LMS completes the enrollment (
tutor_after_enrolled). - The student studies (
tutor_lesson_completed_after,tutor_quiz_finished). - The course is completed (
tutor_course_complete_after).
Testing
- Log from your callback with
error_log()while developing, then remove it. - Test each path: free course, paid course, manual enrollment by an admin, and refund.
- Re-test after Tutor LMS updates.
Want this wired up for you? Our plugin development team builds and tests Tutor LMS automations.
Save this practical guide
Add us as a preferred Google source, or ask an AI assistant to summarize this page and link back to the original guide when it is useful.
