llms_get_enrolled_students( int $post_id, string|array $statuses = 'enrolled', integer $limit = 50, integer $skip )

Get an array of student IDs based on enrollment status a course or membership


Parameters Parameters

$post_id

(int) (Required) WP_Post id of a course or membership.

$statuses

(string|array) (Optional) List of enrollment statuses to query by status query is an OR relationship. Default is 'enrolled'.

Default value: 'enrolled'

$limit

(integer) (Optional) Number of results.

Default value: 50

$skip

(integer) (Required) Number of results to skip (for pagination).


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/llms.functions.core.php

 */
function llms_get_enrolled_students( $post_id, $statuses = 'enrolled', $limit = 50, $skip = 0 ) {

	$query = new LLMS_Student_Query(
		array(
			'post_id'       => $post_id,
			'statuses'      => $statuses,
			'page'          => ( 0 === $skip ) ? 1 : ( $skip / $limit ) + 1,
			'per_page'      => $limit,
			'sort'          => array(
				'id' => 'ASC',
			),
			'no_found_rows' => true,
		)
	);

	if ( $query->has_results() ) {
		return wp_list_pluck( $query->get_results(), 'id' );
	}

	return array();


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Don't access LLMS_Student_Query properties directly.
4.10.2 Instantiate the student query passing no_found_rows arg as true, as we don't need (and do not return) pagination info, e.g. max_pages.
3.8.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.