LLMS_Instructor::get_students( array $args = array() )

Retrieve instructor’s students


Description Description

See also See also


Top ↑

Parameters Parameters

$args

(array) (Optional) Array of args passed to LLMS_Student_Query.

Default value: array()


Top ↑

Return Return

(obj)


Top ↑

Source Source

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

	public function get_students( $args = array() ) {

		$ids = $this->get_posts( array(
			'posts_per_page' => -1,
		), 'ids' );

		// if post IDs were passed we need to verify they're IDs that the instructor has access to.
		if ( $args['post_id'] ) {
			$args['post_id'] = ! is_array( $args['post_id'] ) ? array( $args['post_id'] ) : $args['post_id'];
			$args['post_id'] = array_intersect( $args['post_id'], $ids );
		}

		// not post IDs were passed OR there was no intersections during validation above.
		if ( empty( $args['post_id'] ) ) {
			$args['post_id'] = $ids;
		}

		$query = new LLMS_Student_Query( $args );

		// if there's no post ids "hack" the response
		// @todo add an instructor query parameter to the student query
		if ( ! $ids ) {
			$query->results = array();
		}

		return $query;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.32.0 Validate post_id data passed into this function to ensure only students in courses/memberships for this instructor are returned.
3.13.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: