Skip to content

Instantly share code, notes, and snippets.

Example code for action that runs after Caldera Forms submission is processed, but before it is saved. For more information see: https://calderaforms.com/doc/caldera_forms_submit_post_process/
<?php
add_action( 'caldera_forms_submit_post_process', function( $form, $referrer, $process_id, $entry_id ){
//make sure to set your field ID here.
$field_id = 'fld_123456';
//Get value of a field
$field_value = Caldera_Forms::get_field_data( $field_id, $form , $entry_id);
//check value
if( in_array( $field_value, array( 'Roy', 'Shawn' )) ){
//change value
Caldera_Forms::set_field_data( $field_id, 'Mike', $form, $entry_id );
}
}, 10, 4 );
<?php
add_action( 'caldera_forms_submit_post_process', function( $form, $referrer, $process_id, $entry_id ){
//Save field data from a SESSION var if it is set
if( isset( $_SESSION, $_SESSION[ 'foo' ] ) ){
//make sure to update the field ID
Caldera_Forms::set_field_data( 'fld1234567', $_SESSION[ 'foo' ], $form, $entry_id );
}
}, 10, 4 );
<?php
add_action( 'caldera_forms_submit_post_process', function( $form, $referrer, $process_id, $entry_id ){
//IMPORTANT -- Change the form ID to match your form
if( 'CF57c872a1c80af' == $form[ 'ID' ] ){
//IMPORTANT -- Change the field ID to match your post select field
$field_id = 'fld_5702696';
//get the Post ID from current field value
$post_id = Caldera_Forms::get_field_data( $field_id, $form, $entry_id );
if( is_numeric( $post_id ) ){
//get title, by ID and set it as field value
$title = get_the_title( $post_id );
Caldera_Forms::set_field_data( $field_id, $title, $form, $entry_id );
}
}
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment