FI_SUBMITFORM::fi_submit_form( $entry_id,  $form_id )

Validation function when the trigger action is hit


Parameters Parameters

$entry_id

(Required)

$form_id

(Required)


Source Source

File: src/integrations/formidable/triggers/fi-submitform.php

	public function fi_submit_form( $entry_id, $form_id ) {

		global $uncanny_automator;

		$user_id = get_current_user_id();
		if ( empty( $user_id ) ) {
			return;
		}

		$args = [
			'code'    => $this->trigger_code,
			'meta'    => $this->trigger_meta,
			'post_id' => intval( $form_id ),
			'user_id' => intval( $user_id ),
		];

		$result = $uncanny_automator->maybe_add_trigger_entry( $args, false );

		if ( $result ) {
			foreach ( $result as $r ) {
				if ( true === $r['result'] ) {
					if ( isset( $r['args'] ) && isset( $r['args']['get_trigger_id'] ) ) {
						//Saving form values in trigger log meta for token parsing!
						$fi_args = [
							'trigger_id'     => (int) $r['args']['trigger_id'],
							'meta_key'       => $this->trigger_meta,
							'user_id'        => $user_id,
							'trigger_log_id' => $r['args']['get_trigger_id'],
							'run_number'     => $r['args']['run_number'],
						];

						$uncanny_automator->helpers->recipe->formidable->extract_save_fi_fields( $entry_id, $form_id, $fi_args );
					}
					$uncanny_automator->maybe_trigger_complete( $r['args'] );
				}
			}
		}

	}