Last active
July 7, 2018 05:49
-
-
Save Shelob9/0afea47e2f859011b6a6e3cb4a185bd0 to your computer and use it in GitHub Desktop.
Examples of using caldera_forms_submit_complete hook. See -https://calderaforms.com/doc/caldera_forms_submit_complete/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get a field value and send to remote API | |
*/ | |
add_action( 'caldera_forms_submit_complete', function( $form, $referrer, $process_id ) { | |
//change your form ID here | |
if( 'cf123..' != $form[ 'ID' ] ) { | |
return; | |
} | |
//change your field ID here | |
$data_from_field12345 = Caldera_Forms::get_field_data( 'fld12345', $form ); | |
$remote_api = 'http://api.com/api'; | |
//POST to remote API | |
wp_safe_remote_post( $remote_api, array( 'body' => array( 'something' => $data_from_field12345 ) ) ); | |
}, 10, 3 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'caldera_forms_submit_complete', function( $form ){ | |
global $transdata; | |
if( ! empty( $transdata['edit'] ) ){ | |
$data = null; | |
if( ! empty( $transdata[ 'edit' ] ) ){ | |
$data = $transdata[ 'edit']; | |
} | |
//note that $data is the submission data used to send the email - you can modify it here if needed. | |
Caldera_Forms_Save_Final::do_mailer( $form, $transdata['edit'], $data ); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Save last entry ID, of specific form to user meta | |
*/ | |
add_action( 'caldera_forms_submit_complete', function( $form, $referrer, $process_id, $entry_id ) { | |
//change your form ID here | |
if( 'cf123..' != $form[ 'ID' ] ) { | |
return; | |
} | |
update_user_meta( get_current_user_id(), '_last_entry_id', $entry_id ); | |
}, 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment