How to Run Code When a Course Is Completed
Use tutor_course_complete_after to reward graduates, notify managers or sync completions to an HR system, with how Tutor LMS records completion and a safe example.
Checked against the plugin source: Tutor LMS 4.1.3, Tutor LMS Pro 4.1.3

Course completion is the moment many sites care about most: issue a badge, unlock the next course, notify a manager or record training in an HR system. Tutor LMS fires tutor_course_complete_after at that moment. This guide is verified against Tutor LMS 4.1.3.
Signature
do_action( 'tutor_course_complete_after', $course_id, $user_id );
There is also tutor_course_complete_before, which passes only the course ID and runs just before the completion is saved.
How Tutor LMS stores completion
Completion is saved as a comment on the course with the comment type course_completed and the agent TutorLMSPlugin. The comment content is a unique hash, which Tutor LMS Pro uses as the certificate ID. To check completion in code, call:
$completed = tutor_utils()->is_completed_course( $course_id, $user_id );
// false, or an object with course_id, completed_user_id, completion_date and completed_hash.
When completion happens
Depending on your settings, a student completes a course by clicking the complete button, or Tutor LMS completes it automatically when the Auto Complete Course on All Lesson Completion setting is on. Either way the same hook fires. See how progress is tracked.
Example: email the student's manager
add_action( 'tutor_course_complete_after', 'tle_notify_manager', 10, 2 );
function tle_notify_manager( $course_id, $user_id ) {
$manager_email = get_user_meta( $user_id, 'tle_manager_email', true );
if ( ! is_email( $manager_email ) ) {
return;
}
$user = get_userdata( $user_id );
$course = get_the_title( $course_id );
if ( ! $user || ! $course ) {
return;
}
wp_mail(
$manager_email,
sprintf( '%s completed %s', $user->display_name, $course ),
sprintf( "%s has completed the course \"%s\" on %s.", $user->display_name, $course, wp_date( get_option( 'date_format' ) ) )
);
}
The manager email field is an example; store it however your site collects it, for example a registration field.
More ideas
- Unlock the next course: enroll the student in a follow-up course; see programmatic enrollment.
- Grant a role or capability for a members-only area.
- Send to an HR or LMS reporting system with the completion date and certificate hash.
Things to watch
- A student can retake a course when the Course Retake setting is on, so the hook can fire more than once per student. Guard against double rewards.
- Keep slow work out of the request, or queue it.
- Certificates (Pro) depend on completion. To withhold a certificate under extra rules, use the
tutor_pro_certificate_accessfilter rather than blocking completion.
Frequently asked questions
Is there a hook for lesson completion?
Yes: tutor_lesson_completed_after, with the lesson ID and user ID.
Does this hook fire for bundles?
It fires for each completed course. Bundle-level logic needs your own check across the bundle's courses.
See the hooks reference, or ask our plugin development team to build your completion workflow.
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.
