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

Get all enrolled courses ids


Description

See also


Parameters

$user

(null) (Optional) User object|id

Default value: null

$course_status

(string) (Optional) course status

Default value: 'any'


Return

(array)


Source

File: includes/course-functions.php

	function dozent_get_enrolled_course_ids( $user = null, $course_status = 'any' ) {
		global $wpdb;

		$user    = dozent_user_data( $user );
		$user_id = $user->get_id();

		$status_sql = '';
		if ( $course_status !== 'any' ) {
			$course_status            = (array) $course_status;
			$status_sql_format = dozent_array_to_in_sql( $course_status );
			$status_sql        = " AND post_status IN( {$status_sql_format} ) ";
		}

		$course_ids = $wpdb->get_col( "SELECT course_id 
		FROM {$wpdb->dozent_enrols} 
		WHERE user_id = {$user_id} {$status_sql} 
		ORDER BY CASE 
		    WHEN expired_at IS NOT NULL THEN expired_at
		    ELSE created_at END DESC ;" );

		return $course_ids;
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.