LLMS_Order::get_access_status()

Get the current status of a student’s access


Description Description

Based on the access plan data stored on the order at the time of purchase.


Top ↑

Return Return

(string) 'inactive' If the order is refunded, failed, pending, etc... 'expired' If access has expired according to $this->get_access_expiration_date() 'active' Otherwise.


Top ↑

Source Source

File: includes/models/model.llms.order.php

	public function get_access_status() {

		$statuses = apply_filters(
			'llms_order_allow_access_stasuses',
			array(
				'llms-active',
				'llms-completed',
				'llms-pending-cancel',
				/**
				 * Recurring orders can expire but still grant access
				 * eg: 3monthly payments grants 1 year of access
				 * on the 4th month the order will be marked as expired
				 * but the access has not yet expired based on the data below.
				 */
				'llms-expired',
			)
		);

		// If the order doesn't have one of the allowed statuses.
		// Return 'inactive' and don't bother checking expiration data.
		if ( ! in_array( $this->get( 'status' ), $statuses, true ) ) {

			return 'inactive';

		}

		// Get the expiration date as a timestamp.
		$expires = $this->get_access_expiration_date( 'U' );

		/**
		 * A translated non-numeric string will be returned for lifetime access
		 * so if we have a timestamp we should compare it against the current time
		 * to determine if access has expired.
		 */
		if ( is_numeric( $expires ) ) {

			$now = llms_current_time( 'timestamp' );

			// Expiration date is in the past
			// eg: the access has already expired.
			if ( $expires < $now ) {

				return 'expired';

			}
		}

		// We're active.
		return 'active';

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.2.0 Use stric type comparison.
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.