Happyforms_Helpers::extract_save_hf_fields( $submission,  $form_id,  $args )


Parameters Parameters

$entry_id

(Required)

$form_id

(Required)

$args

(Required)


Top ↑

Return Return

(array)


Source Source

File: src/integrations/happyforms/helpers/happyforms-helpers.php

	public function extract_save_hf_fields( $submission, $form_id, $args ) {
		$data = array();
		if ( ! empty( $submission ) ) {
			$metas          = $submission;
			$trigger_id     = (int) $args['trigger_id'];
			$user_id        = (int) $args['user_id'];
			$trigger_log_id = (int) $args['trigger_log_id'];
			$run_number     = (int) $args['run_number'];
			$meta_key       = (string) $args['meta_key'];

			foreach ( $metas as $field_id => $meta ) {
				$key          = "{$trigger_id}:{$meta_key}:{$form_id}|{$field_id}";
				$data[ $key ] = $meta;
			}

			if ( $data ) {

				$insert = [
					'user_id'        => $user_id,
					'trigger_id'     => $trigger_id,
					'trigger_log_id' => $trigger_log_id,
					'meta_key'       => $meta_key,
					'meta_value'     => maybe_serialize( $data ),
					'run_number'     => $run_number,
				];

				Automator()->insert_trigger_meta( $insert );
			}
		}

		return $data;
	}