LLMS_Post_Instructors::get_instructors( boolean $exclude_hidden = false )
Retrieve course instructor information
Parameters Parameters
- $exclude_hidden
-
(boolean) (Optional) If true, excludes hidden instructors from the return array.
Default value: false
Return Return
(array[]) Array or instructor data arrays.
- 'id'
(int) WP_User ID of the instructor user. - 'visibility'
(string) Display visibility option for the instructor. - 'label'
(string) User input display noun for the instructor. EG: "Author" or "Coach" or "Instructor". - 'name'
(string) WP_User Display Name.
Source Source
File: includes/models/model.llms.post.instructors.php
public function get_instructors( $exclude_hidden = false ) {
$instructors = $this->post->get( 'instructors' );
// If empty, respond with the course author in an array.
if ( ! $instructors ) {
$author_id = $this->post->get( 'author' );
$author = get_userdata( $author_id );
$instructors = array(
wp_parse_args(
array(
'id' => $author_id,
'name' => $author ? $author->display_name : '',
),
llms_get_instructors_defaults()
),
);
}
if ( $exclude_hidden ) {
foreach ( $instructors as $key => $instructor ) {
if ( 'hidden' === $instructor['visibility'] ) {
unset( $instructors[ $key ] );
}
}
}
return $instructors;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.2.0 | Normalize return data when no instructor data is saved. |
| 3.23.0 | Unknown. |
| 3.13.0 | Introduced. |