Wpf_Tokens::wpf_form_save_entry( $fields,  $form_data,  $recipes,  $args )


Parameters Parameters

$fields

(Required)

$form_data

(Required)

$recipes

(Required)

$args

(Required)


Top ↑

Return Return

(null|string)


Source Source

File: src/integrations/wpforms/tokens/wpf-tokens.php

	public function wpf_form_save_entry( $fields, $form_data, $recipes, $args ) {
		if ( is_array( $args ) ) {
			foreach ( $args as $trigger_result ) {
				//$trigger_result = array_pop( $args );
				if ( true === $trigger_result['result'] ) {

					if ( $recipes ) {
						foreach ( $recipes as $recipe ) {
							$triggers = $recipe['triggers'];
							if ( $triggers ) {
								foreach ( $triggers as $trigger ) {
									$trigger_id = $trigger['ID'];
									if ( ! key_exists( 'WPFFORMS', $trigger['meta'] ) ) {
										continue;
									} else {
										$trigger_args = $trigger_result['args'];
										$meta_key     = $trigger_args['meta'];
										$form_id      = $form_data['id'];
										$data         = array();
										if ( $fields ) {
											foreach ( $fields as $field ) {
												$field_id     = $field['id'];
												$key          = "{$trigger_id}:{$meta_key}:{$form_id}|{$field_id}";
												$data[ $key ] = $field['value'];
											}
										}

										$user_id        = (int) $trigger_result['args']['user_id'];
										$trigger_log_id = (int) $trigger_result['args']['get_trigger_id'];
										$run_number     = (int) $trigger_result['args']['run_number'];

										$args = [
											'user_id'        => $user_id,
											'trigger_id'     => $trigger_id,
											'meta_key'       => $meta_key,
											'meta_value'     => maybe_serialize( $data ),
											'run_number'     => $run_number, //get run number
											'trigger_log_id' => $trigger_log_id,
										];

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