automator_save_elementor_form_entry
Fires when an Elementor form entry is saved, passing the entry record and associated recipes.
add_action( 'automator_save_elementor_form_entry', $callback, 10, 3 );
Description
Fires after an Elementor form entry is saved, providing access to the recorded data, associated recipes, and additional arguments. Developers can use this hook to further process or modify the form submission before it's permanently stored.
Usage
add_action( 'automator_save_elementor_form_entry', 'your_function_name', 10, 3 );
Parameters
-
$record(mixed) - This parameter contains the entry record for the submitted Elementor form.
-
$recipes(mixed) - This parameter contains information about the form submission record being processed.
-
$args(mixed) - This parameter contains the recipes that were triggered by the elementor form submission.
Examples
<?php
/**
* Processes and saves Elementor form entry data when the automator_save_elementor_form_entry hook is fired.
*
* This function is designed to be attached to the 'automator_save_elementor_form_entry' action hook.
* It receives the form submission record, associated recipes, and additional arguments.
* The primary goal is to extract relevant data from the form submission and make it available
* as tokens for Uncanny Automator recipes that are triggered by Elementor form submissions.
*
* @param array $record The data associated with the Elementor form submission.
* @param array $recipes The recipes that are potentially being matched by this form submission.
* @param array $args Additional arguments passed to the hook, often containing trigger and recipe IDs.
*/
function my_uncanny_automator_process_elementor_form_entry( $record, $recipes, $args ) {
// Ensure we have valid data to process.
if ( empty( $record ) || empty( $args ) || ! isset( $args['trigger_id'] ) ) {
error_log( 'Uncanny Automator: Missing data for automator_save_elementor_form_entry hook.' );
return;
}
$trigger_id = $args['trigger_id'];
$recipe_id = isset( $args['recipe_id'] ) ? $args['recipe_id'] : null; // Recipe ID might not always be present here.
// Example: Log the form submission data for debugging purposes.
// In a real-world scenario, you might process this data to extract specific field values
// and store them in a format that Uncanny Automator can use as tokens.
error_log( 'Uncanny Automator: Processing Elementor form entry for Trigger ID: ' . $trigger_id );
error_log( 'Uncanny Automator: Form Submission Data: ' . print_r( $record, true ) );
error_log( 'Uncanny Automator: Associated Recipes: ' . print_r( $recipes, true ) );
error_log( 'Uncanny Automator: Additional Args: ' . print_r( $args, true ) );
// If you need to manipulate the data before it's saved as trigger meta for tokens,
// you would do it here. For instance, mapping specific form fields to token names.
// This example assumes Uncanny Automator's core functionality handles the token generation
// based on the $record, $recipes, and $args passed to it.
// If you were to modify the $record or $recipes before they are used by Uncanny Automator,
// you would do so here and potentially return them if this was a filter hook.
// As this is an action hook, modifications happen in place or are handled by Uncanny Automator's internal logic.
}
// Hook into the automator_save_elementor_form_entry action.
// The '10' is the priority, and '3' signifies that this function accepts 3 arguments.
add_action( 'automator_save_elementor_form_entry', 'my_uncanny_automator_process_elementor_form_entry', 10, 3 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/integrations/elementor/triggers/elem-submitform.php:107
src/integrations/elementor/triggers/anon-elem-submitform.php:117
uncanny-automator-pro/src/integrations/elementor/triggers/anon-elem-submitfield.php:123
uncanny-automator-pro/src/integrations/elementor/triggers/elem-submitfield.php:122
public function elem_submit_form( $record, $obj ) {
if ( ! $obj->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 $trigger_id => $recipe_id ) {
$args = array(
'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,
);
$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'] );
}
}
}
}
}
}
Internal Usage
Found in src/integrations/elementor/tokens/elem-tokens.php:21:
add_action( 'automator_save_elementor_form_entry', array( $this, 'elem_save_form_entry' ), 10, 3 );