UT_USER_IMPORTED_IN_COURSE::complete_trigger( $meta_value,  $args,  $course_id )

Running an actual function on the trigger


Parameters Parameters

$meta_value

(Required)

$args

(Required)

$course_id

(Required)


Source Source

File: src/integrations/uncanny-toolkit/triggers/ut-user-imported-in-course.php

	public function complete_trigger( $meta_value, $args, $course_id ) {

		$results                              = Automator()->process->user->maybe_add_trigger_entry( $args, false );
		$meta_value['learndash_course_id']    = $course_id;
		$meta_value['learndash_course_title'] = get_the_title( $course_id );
		$serialized                           = maybe_serialize( $meta_value );
		if ( empty( $results ) ) {
			return;
		}
		foreach ( $results as $rr ) {
			if ( ! $rr['result'] ) {
				continue;
			}
			$trigger_id     = (int) $rr['args']['trigger_id'];
			$user_id        = (int) $rr['args']['user_id'];
			$trigger_log_id = (int) $rr['args']['trigger_log_id'];
			$run_number     = (int) $rr['args']['run_number'];
			$token_args     = array(
				'user_id'        => $user_id,
				'trigger_id'     => $trigger_id,
				'run_number'     => $run_number, //get run number
				'trigger_log_id' => $trigger_log_id,
			);

			Automator()->db->trigger->add_token_meta( 'imported_row', $serialized, $token_args );

			Automator()->process->user->maybe_trigger_complete( $rr['args'] );
		}
	}