MPC_MARKCOURSEDONE::mark_completes_a_course( $user_id,  $action_data,  $recipe_id,  $args )

Validation function when the action is hit


Parameters Parameters

$user_id

(Required)

$action_data

(Required)

$recipe_id

(Required)


Source Source

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

	public function mark_completes_a_course( $user_id, $action_data, $recipe_id, $args ) {
		$sections  = [];
		$lessons   = [];
		$course_id = $action_data['meta'][ $this->action_meta ];
		$sections  = Automator()->helpers->recipe->memberpress_courses->find_all_by_course( $course_id );

		if ( is_array( $sections ) && count( $sections ) > 0 ) {
			foreach ( $sections as $section ) {
				$lessons = Automator()->helpers->recipe->memberpress_courses->find_all_by_section( $section );
				if ( is_array( $lessons ) && count( $lessons ) > 0 ) {
					foreach ( $lessons as $lesson ) {
						$this->mark_lesson_completed( $user_id, $course_id, $lesson, $section );
					}
				}
			}
		}
		Automator()->complete_action( $user_id, $action_data, $recipe_id );
	}