MPC_MARKLESSONDONE::mark_lesson_completed( $user_id,  $course_id,  $lesson_id )


Parameters Parameters

$user_id

(Required)

$course_id

(Required) $ @param $lesson_id


Source Source

File: src/integrations/memberpress-courses/actions/mpc-marklessondone.php

	public function mark_lesson_completed( $user_id, $course_id, $lesson_id ) {

		if ( empty( $lesson_id ) && empty( $course_id ) ) {
			return;
		}

		if ( models\UserProgress::has_completed_course( $user_id, $course_id ) ) {
			return;
		}

		$user_progress               = new models\UserProgress();
		$user_progress->lesson_id    = $lesson_id;
		$user_progress->course_id    = $course_id;
		$user_progress->user_id      = $user_id;
		$user_progress->created_at   = lib\Utils::ts_to_mysql_date( time() );
		$user_progress->completed_at = lib\Utils::ts_to_mysql_date( time() );
		$user_progress->store();

		do_action( base\SLUG_KEY . '_completed_lesson', $user_progress );
	}