LLMS_Instructor::get_students( array $args = array() )
Retrieve instructor’s students
Description Description
See also See also
Parameters Parameters
- $args
-
(array) (Optional) Array of args passed to LLMS_Student_Query.
Default value: array()
Return Return
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 ( ! empty( $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 ); } else { // No post IDs passed in, query all of the instructor's posts. $args['post_id'] = $ids; } // The instructor has no posts, so we want to force no results. // @todo add an instructor query parameter to the student query. if ( empty( $args['post_id'] ) ) { $args['per_page'] = 0; $args['no_found_rows'] = true; } return new LLMS_Student_Query( $args ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Don't access LLMS_Student_Query properties directly. |
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. |