ANON_CF_SUBFORM::caldera_forms_submit( $form,  $referrer,  $process_id,  $entryid )

Validation function when the trigger action is hit


Parameters Parameters

$form

(Required)

$referrer

(Required)


Source Source

File: src/integrations/caldera-forms/triggers/anon-cf-subform.php

	public function caldera_forms_submit( $form, $referrer, $process_id, $entryid ) {

		$user_id    = get_current_user_id();
		$recipes    = Automator()->get->recipes_from_trigger_code( $this->trigger_code );
		$conditions = $this->match_condition( $form, $recipes, $this->trigger_meta, $this->trigger_code );

		if ( empty( $conditions ) ) {
			return;
		}

		foreach ( $conditions['recipe_ids'] as $trigger_id => $recipe_id ) {
			if ( Automator()->is_recipe_completed( $recipe_id, $user_id ) ) {
				continue;
			}
			$args = [
				'code'             => $this->trigger_code,
				'meta'             => $this->trigger_meta,
				'recipe_to_match'  => $recipe_id,
				'trigger_to_match' => $trigger_id,
				'ignore_post_id'   => true,
				'user_id'          => $user_id,
			];

			Automator()->process->user->maybe_add_trigger_entry( $args );

		}
	}