ELEM_SUBMITFORM::elem_submit_form( object $record, object $object )

Validation function when the trigger action is hit


Parameters Parameters

$record

(object) (Required)

$object

(object) (Required)


Source Source

File: src/integrations/elementor/triggers/elem-submitform.php

	public function elem_submit_form( $record, $object ) {

		if ( ! $object->is_success ) {
			return;
		}

		$form_id = $record->get_form_settings( 'id' );
		if ( empty( $form_id ) ) {
			return;
		}


		$user_id    = wp_get_current_user()->ID;
		$recipes    = Automator()->get->recipes_from_trigger_code( $this->trigger_code );
		$conditions = $this->match_condition( $form_id, $recipes, $this->trigger_meta, $this->trigger_code );

		if ( ! $conditions ) {
			return;
		}

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

					$args = Automator()->maybe_add_trigger_entry( $args, false );
					do_action( 'automator_save_elementor_form_entry', $record, $recipes, $args );
					if ( $args ) {
						foreach ( $args as $result ) {
							if ( true === $result['result'] ) {
								Automator()->maybe_trigger_complete( $result['args'] );
							}
						}
					}
				}
			}
		}
	}