Divi_Helpers::save_tokens( $result,  $fields_values,  $form_id,  $trigger_meta,  $user_id )

Saving tokens


Parameters Parameters

$result

(Required)

$fields_values

(Required)

$form_id

(Required)

$trigger_meta

(Required)

$user_id

(Required)


Source Source

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

	public static function save_tokens( $result, $fields_values, $form_id, $trigger_meta, $user_id ) {
		if ( empty( $result ) ) {
			return;
		}
		if ( false === $result['result'] ) {
			return;
		}
		$all_fields = array();
		foreach ( $fields_values as $k => $v ) {
			$field_id                = "$form_id|$k";
			$all_fields[ $field_id ] = $v['value'];
		}
		$trigger_id     = $result['args']['trigger_id'];
		$trigger_log_id = absint( $result['args']['trigger_log_id'] );
		$run_number     = absint( $result['args']['run_number'] );
		$meta_key       = sprintf( '%d:%s', $trigger_id, $trigger_meta );
		$trigger_meta   = array(
			'user_id'        => $user_id,
			'trigger_id'     => $trigger_id,
			'trigger_log_id' => $trigger_log_id,
			'run_number'     => $run_number,
		);

		Automator()->db->token->save( $meta_key, maybe_serialize( $all_fields ), $trigger_meta );
	}