LLMS_Controller_Orders::expire_access( int $order_id )
Handle expiration & cancellation from a course / membership 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
Description Description
Parameters Parameters
- $order_id
-
(int) (Required) WP Post ID of the LLMS Order
Return Return
(void)
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 ); } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: