Wp_Fluent_Forms_Helpers::extract_save_wp_fluent_form_fields( $insert_data,  $form,  $args )


Parameters Parameters

$insert_data

(Required)

$form

(Required)

$args

(Required)


Top ↑

Return Return

(array)


Source Source

File: src/integrations/wp-fluent-forms/helpers/wp-fluent-forms-helpers.php

	public function extract_save_wp_fluent_form_fields( $insert_data, $form, $args ) {
		$data = array();
		if ( $form && function_exists( 'wpFluent' ) ) {
			//$fields  = $form['fields'];
			$form_id        = (int) $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 ( $insert_data ) {
				foreach ( $insert_data as $field_id => $field_data ) {
					if ( is_array( $field_data ) ) {
						foreach ( $field_data as $d_d => $d_v ) {
							$child_field_id = $d_d;
							$key            = "{$trigger_id}:{$meta_key}:{$form_id}|{$field_id}|{$child_field_id}";
							$data[ $key ]   = $d_v;
						}
						continue;
					}
					$key          = "{$trigger_id}:{$meta_key}:{$form_id}|{$field_id}";
					$data[ $key ] = $field_data;
				}
			}

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