LLMS_Controller_Lesson_Progression::handle_complete_form()

Mark Lesson as complete


Description Description

  • Complete Lesson form post.
  • Marks lesson as complete and returns completion message to user.
  • Autoadvances to next lesson if completion is successful.

Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/controllers/class.llms.controller.lesson.progression.php

	public function handle_complete_form() {

		$lesson_id = $this->get_lesson_id_from_form_data( 'complete' );

		if ( is_null( $lesson_id ) ) {
			return;
		}

		/**
		 * Filter to modify the user id instead of current logged in user id.
		 *
		 * @param int $user_id User id to mark lesson as complete.
		 *
		 * @since 5.4.0
		 */
		$user_id = apply_filters( 'llms_lesson_completion_user_id', get_current_user_id() );

		do_action( 'llms_trigger_lesson_completion', $user_id, $lesson_id, 'lesson_' . $lesson_id );

		if ( apply_filters( 'lifterlms_autoadvance', true ) ) {

			$lesson         = new LLMS_Lesson( $lesson_id );
			$next_lesson_id = $lesson->get_next_lesson();
			if ( $next_lesson_id ) {

				wp_redirect( apply_filters( 'llms_lesson_complete_redirect', get_permalink( $next_lesson_id ) ) );
				exit;

			}
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.29.0 Unknown.
3.17.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.