Development

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

Tutor LMS Action Hooks: Enrollment, Completion and Orders

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_cancelled and tutor_after_enrollment_deleted pass the course ID and user ID.
  • tutor/course/enrol_status_change/after passes 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.

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

  1. Checkout creates the order (tutor_order_placed) and a pending enrollment (tutor_after_enroll).
  2. The gateway confirms payment, and the order changes to paid (tutor_order_payment_status_changed).
  3. Tutor LMS completes the enrollment (tutor_after_enrolled).
  4. The student studies (tutor_lesson_completed_after, tutor_quiz_finished).
  5. 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.

Vishavjeet
· Enterprise LMS Architect | WordPress & LMS Expert | WooCommerce | AI Automation

I’m Vishavjeet Choubey, an Enterprise LMS Architect with 10+ years of experience helping businesses, coaches, universities, and online academies build and scale powerful digital learning platforms. I specialize in enterprise LMS architecture, WordPress, WooCommerce, LifterLMS, LearnDash, Moodle, custom plugin development, and AI-driven automation. I build scalable LMS platforms, high-converting eCommerce solutions, and custom WordPress applications designed to improve user experiences, streamline operations, and drive measurable business growth. My approach combines deep WordPress and LMS engineering expertise with modern AI automation to reduce manual work, improve efficiency, and help organizations launch, scale, and grow faster.

Keep reading

Need a custom Tutor LMS solution?

Tell us what you are building or what is broken. A Tutor LMS developer reads every inquiry and replies with next steps and a free estimate.

Get a free Tutor LMS consultation

Tell us what you are building or fixing. A Tutor LMS developer replies with honest advice and next steps.

  • No obligation
  • Tutor LMS and Pro specialists
  • Your details stay private

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.