UT_RESETUSERSTIMEINCOURSE::process_action( $user_id,  $action_data,  $recipe_id,  $args )

Validation function when the trigger action is hit


Parameters Parameters

$user_id

(Required)

$action_data

(Required)

$recipe_id

(Required)


Source Source

File: src/integrations/uncanny-toolkit/actions/ut-resetuserstimeincourse.php

	public function process_action( $user_id, $action_data, $recipe_id, $args ) {

		$active_modules = get_option( 'uncanny_toolkit_active_classes', true );
		if ( ! isset( $active_modules['uncanny_pro_toolkit\CourseTimer'] ) && empty( $active_modules['uncanny_pro_toolkit\CourseTimer'] ) ) {
			$error_message                       = esc_html__( 'Simple course timer module is not active.', 'uncanny-automator' );
			$action_data['do-nothing']           = true;
			$action_data['complete_with_errors'] = true;
			Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_message );
			return;
		}

		$ut_course_id = Automator()->parse->text( $action_data['meta'][ $this->action_meta ], $recipe_id, $user_id, $args );
		if ( empty( $ut_course_id ) ) {
			$error_message                       = esc_html__( 'The selected course is not found.', 'uncanny-automator' );
			$action_data['do-nothing']           = true;
			$action_data['complete_with_errors'] = true;
			Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_message );

			return;
		}

		if ( ! class_exists( '\uncanny_pro_toolkit\CourseTimer' ) ) {
			$error_message                       = esc_html__( 'Simple course timer module is not active.', 'uncanny-automator' );
			$action_data['do-nothing']           = true;
			$action_data['complete_with_errors'] = true;
			Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_message );

			return;
		}
		if ( ! method_exists( '\uncanny_pro_toolkit\CourseTimer', 'delete_user_course_data' ) ) {
			$error_message                       = esc_html__( 'A required method is not available. Please update Uncanny Toolkit Pro to the latest version.', 'uncanny-automator' );
			$action_data['do-nothing']           = true;
			$action_data['complete_with_errors'] = true;
			Automator()->complete_action( $user_id, $action_data, $recipe_id, $error_message );

			return;
		}

		uncanny_pro_toolkit\CourseTimer::delete_user_course_data( $user_id, $ut_course_id );

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