LF_MARKSECTIONDONE::lf_mark_section_done( string $user_id, array $action_data, string $recipe_id )

Validation function when the action is hit.


Parameters Parameters

$user_id

(string) (Required) user id.

$action_data

(array) (Required) action data.

$recipe_id

(string) (Required) recipe id.


Source Source

File: src/integrations/lifterlms/actions/lf-marksectiondone.php

	public function lf_mark_section_done( $user_id, $action_data, $recipe_id ) {



		if ( ! function_exists( 'llms_mark_complete' ) ) {
			$error_message = 'The function llms_mark_complete does not exist';
			Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_message );

			return;
		}

		$section_id = $action_data['meta'][ $this->action_meta ];

		// Get all lessons of section.
		$section = new LLMS_Section( $section_id );
		$lessons = $section->get_lessons();
		if ( ! empty( $lessons ) ) {
			foreach ( $lessons as $lesson ) {
				llms_mark_complete( $user_id, $lesson->id, 'lesson' );
			}
		}

		llms_mark_complete( $user_id, $section_id, 'section' );

		Automator()->complete_action( $user_id, $action_data, $recipe_id );
	}