llms_is_user_enrolled( int $user_id, int|int[] $product_id, string $relation = 'all', bool $use_cache = true )

Checks if user is currently enrolled courses, sections, lessons, or memberships.


Description Description

See also See also


Top ↑

Parameters Parameters

$user_id

(int) (Required) WP_User ID.

$product_id

(int|int[]) (Required) WP Post ID of a Course, Lesson, or Membership or array of multiple IDs.

$relation

(string) (Optional) Comparator for enrollment check.<br> All = user must be enrolled in all $product_ids.<br> Any = user must be enrolled in at least one of the $product_ids.

Default value: 'all'

$use_cache

(bool) (Optional) If true, returns cached data if available, if false will run a db query.

Default value: true


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/functions/llms.functions.person.php

function llms_is_user_enrolled( $user_id, $product_id, $relation = 'all', $use_cache = true ) {
	$student = new LLMS_Student( $user_id );
	return $student->exists() ?
		$student->is_enrolled( $product_id, $relation, $use_cache ) :
		false;
}


Top ↑

Changelog Changelog

Changelog
Version Description
7.1.0 From now on this function will always return false for non existing users, e.g. deleted users.
3.25.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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