Selling Courses

How to Run Code When a Tutor LMS Order Is Paid

Use the tutor_order_payment_status_changed action to react to paid, refunded and cancelled orders in Tutor LMS native eCommerce, with a safe example and the edge cases to handle.

Checked against the plugin source: Tutor LMS 4.1.3, Tutor LMS Pro 4.1.3

How to Run Code When a Tutor LMS Order Is Paid

When you sell with Tutor LMS's native eCommerce engine, orders live in Tutor LMS's own tables, not in WooCommerce. To send a paid order to a CRM, accounting tool or welcome sequence, listen to the tutor_order_payment_status_changed action. This guide is based on Tutor LMS 4.1.3 (free plugin).

The hook

do_action( 'tutor_order_payment_status_changed', $order_id, $prev_payment_status, $new_payment_status );

Payment statuses are constants on Tutor\Models\OrderModel: PAYMENT_PAID (paid), PAYMENT_UNPAID, PAYMENT_PENDING, PAYMENT_FAILED, PAYMENT_REFUNDED and PAYMENT_PARTIALLY_REFUNDED.

Where it fires

  • Gateway webhooks: when a gateway reports a new payment status, Tutor LMS updates the order and fires the hook with the previous and new status.
  • Mark as paid: when an admin marks a manual order as paid, it fires with unpaid to paid.
  • Refunds: after a refund from the order screen, it fires with the new status (refunded or partially-refunded).
  • Cancel and bulk actions: the previous status is an empty string, and the third argument is the action used, for example cancelled or trash, which are order statuses rather than payment statuses.

Two cases do not go through this hook: a free checkout and an order that is already paid when it is placed. Those use tutor_order_placement_success (with the order ID) and tutor_order_placed. If you need every successful purchase, listen to both.

A safe example: notify a CRM when an order is paid

Tutor LMS itself listens to this hook at priority 10 to update enrollments and earnings. Use a later priority so the student is already enrolled when your code runs. Put this in a small custom plugin, not in your theme.

use Tutor\Models\OrderModel;

add_action( 'tutor_order_payment_status_changed', 'tle_order_paid', 20, 3 );

function tle_order_paid( $order_id, $prev_status, $new_status ) {
	if ( OrderModel::PAYMENT_PAID !== $new_status || OrderModel::PAYMENT_PAID === $prev_status ) {
		return; // Only the moment an order becomes paid.
	}

	$order = ( new OrderModel() )->get_order_by_id( $order_id );
	if ( ! $order ) {
		return;
	}

	$items = array();
	foreach ( $order->items as $item ) {
		$items[] = array(
			'id'    => $item->id,    // Course, bundle or plan ID.
			'title' => $item->title,
			'type'  => $item->type,  // Post type.
		);
	}

	wp_remote_post(
		'https://crm.example.com/hooks/tutor-order',
		array(
			'timeout' => 5,
			'body'    => wp_json_encode(
				array(
					'order_id' => (int) $order->id,
					'email'    => $order->student->email,
					'name'     => $order->student->name,
					'total'    => $order->total_price,
					'items'    => $items,
				)
			),
			'headers' => array( 'Content-Type' => 'application/json' ),
		)
	);
}

get_order_by_id() returns the order with a student object (id, name, email) and an items list. It returns false for an unknown ID, so always check it.

Things to handle

  • Repeat calls: a gateway can send the same webhook more than once. The check on the previous status helps, but store your own "sent" flag if duplicates would cause harm.
  • Slow services: the hook runs inside the webhook or admin request. Keep the timeout short, or queue the work with Action Scheduler or WP-Cron.
  • Refunds: react to refunded to revoke access in other systems. Inside Tutor LMS, the refund dialog asks the admin whether to remove the enrollment, and developers can decide with the tutor_cancel_enrollment_on_refund filter.
  • Subscriptions: renewal orders from the Pro Subscription add-on use the same order system, and order_type tells you if an order is a single_order, subscription or renewal.

WooCommerce stores

This hook belongs to native eCommerce. If WooCommerce is your engine, use WooCommerce's own order hooks; see how WooCommerce orders drive enrollment.

Frequently asked questions

Should I use this hook or tutor_after_enrolled?

Use tutor_after_enrolled for "a student got access", whatever the source. Use this hook for money: payments, refunds and order data.

Is this hook available without Tutor LMS Pro?

Yes. Native eCommerce and this hook are in the free plugin.

Need a reliable order integration? Our plugin development team builds and tests them.

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.