LLMS_Access_Plan::is_available_to_user( int $user_id = null )

Determine if the plan is available to a user based on configured availability restrictions


Parameters Parameters

$user_id

(int) (Optional) (optional) WP User ID, if not supplied get_current_user_id() will be used

Default value: null


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: includes/models/model.llms.access.plan.php

		$user_id = empty( $user_id ) ? get_current_user_id() : $user_id;

		$access = true;

		// If there are membership restrictions, check the user is in at least one membership.
		if ( $this->has_availability_restrictions() ) {
			$access = false;
			foreach ( $this->get_array( 'availability_restrictions' ) as $mid ) {

				// Once we find a membership, exit.
				if ( llms_is_user_enrolled( $user_id, $mid ) ) {
					$access = true;
					break;
				}
			}
		}

		return apply_filters( 'llms_plan_is_available_to_user', $access, $user_id, $this );

	}



Top ↑

Changelog Changelog

Changelog
Version Description
3.4.4 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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