Caldera Forms Run Action

Caldera Forms Run Action Banner

Trigger an action with your form submission. A simple, free form processor for Caldera Forms that lets you do anything with your form data.

This add-on is aimed at experienced WordPress developers who want an easy way to expose form submission data via the WordPress plugins API. For more information on how to use this processor, and other ways to create custom form data processing, see this tutorial.

add_action( 'my_text_action', 'my_test_function');
function my_test_function( $data ) {
    if ( isset( $data[ 'field_id_with_meta_value' ] ) && isset( $data[ 'field_with_post_id' ] ) && 0 < absint( $data[ 'field_with_post_id' ] ) ) {

        update_post_meta( $data[ 'field_with_post_id' ], 'meta_key_name', strip_tags( $data[ 'field_id_with_meta_value' ] )  );
    }
    
}
add_action('my_text_action', 'my_test_function');
function my_test_function( $data ){
    update_option( 'test_form_option', $data );
}

Now With More Control

Using Caldera Forms To Execute a filterVersion 1.0.1 adds the ability to change when the hook is fired and whether to use an action or a filter. Using a filter allows you to modify the form submission data, during processing.

The hook can now run as a preprocessor, processor or postprocessor. Preprocessors are generally used to validate data. If they return any data, it will be break processing of a form. Here is an example where an error message is conditionally returned, using a preprocessor.

add_filter( 'my_custom_pre_filter', 'my_custom_pre_filter' );
function my_custom_pre_filter( $data ) {
    if ( 'something' != $data[ 'something' ] ) {
        return array(
            'type' => 'error',
            'note' => __( 'Something is not right', 'my-text-domain' )
        );
        
    }

}

This would require a preprocessor, filter.

Processor type hooks should be used when you want to assume that data has already been validated. Postprocessor type hooks should be used when you want to run your hook as late as possible. This is useful when you are combing this processor with other processors and only want to fire the hook when no errors occur.

You can also use this processor to save the form entry ID as user meta.

add_action( 'my_text_action', 'my_test_function');
function my_test_function( $data ) {
    $user = get_current_user_id();
    if ( $user && isset( $data[ '__entry_id' ] ) && 0 < absint( $data[ '__entry_id' ] ) ) {
 
        update_user_meta( $users, 'meta_key_name', $data[ '__entry_id' ] )  );
    }
    
}

has been added to your cart!

have been added to your cart!

has been added to your cart!

have been added to your cart!

See All Of Our Cost Saving Bundles

Join Our Newsletter

Get helpful WordPress resources from our lead developer Josh Pollock, Caldera updates, and special savings.