Course::has_permission( $user = null )


Source

File: classes/Course.php

	public function has_permission( $user = null ) {
		$user = dozent_user_data( $user );


		if ( $this->is_public() ) {

			/**
			 * Filter the course permission
			 *
			 * @since DozentLMS 1.0.0
			 *
			 * @param  bool  $bool  Bool
			 * @param  object  $course  course Object
			 * @param  object  $user  User Object
			 */

			return apply_filters( 'course_has_permission', true, $this, $user );
		}

		if ( ! is_user_logged_in() ) {
			return apply_filters( 'course_has_permission', false, $this, $user );
		}

		/**
		 * Given access to protected status = need only logged in
		 * Close Status: need to enrol by purchasing product or course
		 */

		if ( $this->is_protected() || dozent_course_is_enrolled( $this->id, $user, true ) ) {
			return apply_filters( 'course_has_permission', true, $this, $user );
		}

		/**
		 * TODO: Need Check Membership Permission and Group Enrolment Permission
		 */

		/**
		 * Filter course permission
		 *
		 * @since DozentLMS 1.0.0
		 * @param bool $bool Default False
		 * @param object|int $user User Object or ID
		 */

		return apply_filters( 'course_has_permission', false, $this, $user );
	}