dozent_get_enrolled_courses( null $user = null, string $course_status = 'any' )

Get all enrolled courses by specific user


Description

See also


Parameters

$user

(null) (Optional) User Object or ID

Default value: null

$course_status

(string) (Optional) courses status

Default value: 'any'


Return

(bool|WP_Query)


Source

File: includes/course-functions.php

	function dozent_get_enrolled_courses( $user = null, $course_status = 'any' ) {
		$user    = dozent_user_data( $user );
		$user_id = $user->get_id();

		$course_ids = dozent_get_enrolled_course_ids( $user_id, $course_status );

		if ( dozent_count( $course_ids ) ) {

			$paged = ( dozent_input_text( 'current_page' ) ) ? (int) dozent_input_text( 'current_page' ) : 1;

			$per_page = dozent_show_per_page();

			$course_args = [
				'post_type'      => 'dozent_course',
				'post_status'    => 'publish',
				'post__in'       => $course_ids,
				//'posts_per_page' => - 1,
				'posts_per_page' => $per_page,
				'paged'          => $paged
			];

			return new \WP_Query( $course_args );
		}

		return false;
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.