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

(LLMS_Student_Query)


Top ↑

Source Source

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

192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
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 );
 
}


Top ↑

Changelog 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.

Top ↑

User Contributed Notes User Contributed Notes

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