Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/0afea47e2f859011b6a6e3cb4a185bd0 to your computer and use it in GitHub Desktop.
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/
<?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 );
<?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 );
}
});
<?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