UT_USER_IMPORTED::a_user_is_imported( $user_id,  $csv_data,  $csv_header,  $key_location )

Running an actual function on the trigger


Parameters Parameters

$user_id

(Required)

$csv_data

(Required)

$csv_header

(Required)

$key_location

(Required)


Source Source

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

	public function a_user_is_imported( $user_id, $csv_data, $csv_header, $key_location ) {
		if ( ! is_numeric( $user_id ) ) {
			return;
		}
		$meta_value = Uncanny_Toolkit_Helpers::build_token_data( $csv_data, $csv_header, $key_location, $user_id );

		$args = array(
			'code'           => $this->trigger_code,
			'meta'           => $this->trigger_meta,
			'ignore_post_id' => true,
			'user_id'        => $user_id,
			'is_signed_in'   => true,
		);

		$results = Automator()->process->user->maybe_add_trigger_entry( $args, false );

		$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'] );
		}
	}