Ninja_Forms_Helpers::extract_save_ninja_fields( $entry,  $args )


Parameters Parameters

$entry

(Required)

$args

(Required)


Top ↑

Return Return

(array)


Source Source

File: src/integrations/ninja-forms/helpers/ninja-forms-helpers.php

	public function extract_save_ninja_fields( $entry, $args ) {
		$data = array();
		if ( $entry && class_exists( '\Ninja_Forms' ) ) {
			$fields  = $entry['fields'];
			$form_id = (int) $entry['form_id'];

			$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'];
			if ( $fields ) {
				foreach ( $fields as $field ) {
					$field_id     = $field['id'];
					$key          = "{$trigger_id}:{$meta_key}:{$form_id}|{$field_id}";
					$data[ $key ] = $field['value'];
				}
			}

			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;
	}