LLMS_Controller_Orders::expire_access( int $order_id )

Handle expiration & cancellation from a course / membership.


Description Description

Called via scheduled action set during order completion for plans with a limited access plan. Additionally called when an order is marked as "pending-cancel" to revoke access at the end of a pre-paid period.


Top ↑

Parameters Parameters

$order_id

(int) (Required) WP_Post ID of the LLMS Order.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/controllers/class.llms.controller.orders.php

	public function expire_access( $order_id ) {

		$order            = new LLMS_Order( $order_id );
		$new_order_status = false;

		// Pending cancel moves to cancelled.
		if ( 'llms-pending-cancel' === $order->get( 'status' ) ) {

			$status           = 'cancelled';
			$note             = __( 'Student unenrolled at the end of access period due to subscription cancellation.', 'lifterlms' );
			$new_order_status = 'cancelled';

			// All others move to expired.
		} else {

			$status = 'expired';
			$note   = __( 'Student unenrolled due to automatic access plan expiration', 'lifterlms' );

		}

		llms_unenroll_student( $order->get( 'user_id' ), $order->get( 'product_id' ), $status, 'order_' . $order->get( 'id' ) );
		$order->add_note( $note );
		$order->unschedule_recurring_payment();

		if ( $new_order_status ) {
			$order->set_status( $new_order_status );
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.19.0 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.