LLMS_Student::is_enrolled( int|array $product_ids = null, string $relation = 'all', bool $use_cache = true )

Determine if a student is enrolled in a Course or Membership.


Description Description

See also See also


Top ↑

Parameters Parameters

$product_ids

(int|array) (Optional) WP Post ID of a Course, Section, Lesson, or Membership or array of multiple IDs.

Default value: null

$relation

(string) (Optional) Comparator for enrollment check. All = user must be enrolled in all $product_ids. 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

(boolean)


Top ↑

Source Source

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

		// Returns an array with errored keys or true on success.
		return is_array( $update ) ? false : true;

	}

	/**
	 * Remove student enrollment postmeta for a given product.
	 *
	 * @since 3.33.0
	 *
	 * @param int    $product_id WP Post ID of the course or membership.
	 * @param string $trigger    Optional. String the reason for enrollment. Default `null`
	 * @return bool Whether or not the enrollment records have been succesfully removed.
	 */
	private function delete_enrollment_postmeta( $product_id, $trigger = null ) {

		// Delete info from the user postmeta table.
		$user_metadatas = array(
			'_enrollment_trigger' => $trigger,
			'_start_date'         => null,
			'_status'             => null,
		);

		$delete = llms_bulk_delete_user_postmeta( $this->get_id(), $product_id, $user_metadatas );

		return is_array( $delete ) ? false : true;
	}

	/**
	 * Add a new status record to the user postmeta table for a specific product
	 *
	 * @param    int    $product_id   WP Post ID of the course or membership
	 * @param    string $status       string describing the new status
	 * @param    string $trigger  String describing the reason for enrollment (optional)


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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