Wplms_Tokens::automator_wplms_save_tokens_func( $args,  $result )


Parameters Parameters

$args

(Required)

$result

(Required)


Top ↑

Return Return

(void)


Source Source

File: src/integrations/wplms/tokens/wplms-tokens.php

	public function automator_wplms_save_tokens_func( $args, $result ) {
		if ( ! isset( $args['action'] ) ) {
			return;
		}
		$action         = $args['action'];
		$user_id        = $args['user_id'];
		$trigger_id     = (int) $result['trigger_id'];
		$trigger_log_id = (int) $result['get_trigger_id'];
		$run_number     = (int) $result['run_number'];

		$args = array(
			'user_id'        => $user_id,
			'trigger_id'     => $trigger_id,
			'run_number'     => $run_number, //get run number
			'trigger_log_id' => $trigger_log_id,
			'meta_value'     => maybe_serialize( $args ),
		);
		switch ( $action ) {
			case 'unit_completed':
				$args['meta_key'] = 'WPLMSUNITCOMPLETED_tokens';
				break;
			case 'quiz_completed':
				$args['meta_key'] = 'WPLMSQUIZCOMPLETED_tokens';
				break;
			case 'course_started':
				$args['meta_key'] = 'WPLMSCOURSESTARTED_tokens';
				break;
			case 'course_completed':
				$args['meta_key'] = 'WPLMSCOURSECOMPLETED_tokens';
				break;
		}
		Automator()->insert_trigger_meta( $args );
	}