Action uncanny-automator

automator_kadence_form_submitted

Fires after a Kadence Form is successfully submitted, providing access to form data, unique ID, and post ID.

add_action( 'automator_kadence_form_submitted', $callback, 10, 3 );

Description

Fires after a Kadence form is successfully submitted. Developers can use this action to perform custom tasks, such as sending notifications, updating user data, or integrating with other services, based on the submitted form fields and identifiers.


Usage

add_action( 'automator_kadence_form_submitted', 'your_function_name', 10, 3 );

Parameters

$fields_data (mixed)
This parameter contains the submitted data from the Kadence form, typically as an array of field names and their corresponding values.
$unique_id (mixed)
This parameter contains an array of all the form fields and their submitted values.
$post_id (mixed)
This parameter stores a unique identifier for the form submission, which can be used to track specific submissions.

Examples

/**
 * Example callback function for the 'automator_kadence_form_submitted' action hook.
 * This function will be executed whenever a Kadence form is successfully submitted.
 * It logs the submitted fields, a unique identifier for the form submission,
 * and the ID of the post where the form was embedded.
 *
 * @param mixed $fields_data   An array or object containing the submitted form field data.
 * @param mixed $unique_id     A unique identifier for this specific form submission.
 * @param mixed $post_id       The ID of the WordPress post where the form was submitted.
 */
function my_automator_handle_kadence_form_submission( $fields_data, $unique_id, $post_id ) {
    // Ensure we have valid data before proceeding
    if ( ! empty( $fields_data ) && ! empty( $unique_id ) && ! empty( $post_id ) ) {

        // For demonstration purposes, we'll log the data.
        // In a real scenario, you might use this data to trigger other actions,
        // update user profiles, send emails, or interact with other services.

        // Example: Log the submitted data to the WordPress debug log.
        // Make sure WP_DEBUG and WP_DEBUG_LOG are enabled in your wp-config.php for this to work.
        error_log( 'Kadence form submitted! Unique ID: ' . $unique_id . ', Post ID: ' . $post_id );
        error_log( 'Submitted Fields Data: ' . print_r( $fields_data, true ) );

        // Example: If you wanted to conditionally process the data based on a specific field.
        // Assuming there's a field named 'contact_reason' in the form.
        if ( isset( $fields_data['contact_reason'] ) && $fields_data['contact_reason'] === 'support' ) {
            error_log( 'Support request received. Initiating support workflow...' );
            // Potentially call another function to handle support requests.
            // process_support_request( $fields_data, $unique_id, $post_id );
        }

        // Example: If you wanted to store this submission in custom metadata or a custom post type.
        // update_post_meta( $post_id, 'kadence_form_submission_' . $unique_id, array(
        //     'fields'    => $fields_data,
        //     'submitted_at' => current_time( 'mysql' )
        // ) );
    } else {
        error_log( 'automator_kadence_form_submitted hook called with insufficient data.' );
    }
}

// Add the callback function to the 'automator_kadence_form_submitted' action hook.
// The '10' is the priority (default), and '3' indicates that the callback function accepts 3 arguments.
add_action( 'automator_kadence_form_submitted', 'my_automator_handle_kadence_form_submission', 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/kadence/helpers/kadence-helpers.php:34

public function automator_kadence_form_submitted_function( $first_arg, $second_arg, $third_arg, $forth_arg = 0 ) {

		if ( current_action() === 'kadence_blocks_advanced_form_submission' ) {
			$fields_data = $second_arg;
			$unique_id   = null;
			$post_id     = $third_arg;
		}

		if ( current_action() === 'kadence_blocks_form_submission' ) {
			$fields_data = $second_arg;
			$unique_id   = $third_arg;
			$post_id     = $forth_arg;
		}

		do_action( 'automator_kadence_form_submitted', $fields_data, $unique_id, $post_id );

	}

Internal Usage

Found in src/integrations/kadence/triggers/kadence-anon-form-submitted.php:28:

$this->add_action( 'automator_kadence_form_submitted', 10, 3 );

Found in src/integrations/kadence/triggers/kadence-form-submitted.php:27:

$this->add_action( 'automator_kadence_form_submitted', 10, 3 );

Found in uncanny-automator-pro/src/integrations/kadence/triggers/kadence-user-submitted-form-with-specific-value.php:27:

$this->add_action( 'automator_kadence_form_submitted', 10, 3 );
Scroll to Top