Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active September 17, 2017 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/cf1e43043987a9a413cc07374116cda2 to your computer and use it in GitHub Desktop.
Save Shelob9/cf1e43043987a9a413cc07374116cda2 to your computer and use it in GitHub Desktop.
Delete Caldera Forms entry after the message is sent. caldera_forms_submit_complete hook. See: https://calderaforms.com/doc/delete-entry-sent/
<?php
/**
* Delete a message from database once submission is complete
*
* Deletes from Caldera Forms Pro, which needs local DB storage to send.
*/
add_filter( 'caldera_forms_submit_complete',
function( $form, $referrer, $process_id, $entry_id ){
//Delete from Caldera Forms Pro if API client is active
if( defined( 'CF_PRO_VER' ) ) {
$api_client = \calderawp\calderaforms\pro\container::get_instance()->get_api_client();
//requires v0.10.0+
if( method_exists( $api_clint, 'delete_by_local_id' )){
$api_client->delete_by_local_id( $entry_id );
}
}
//Delete in local database
Caldera_Forms_Entry_Bulk::delete_entries( array( $entry_id ) );
},
//Keep priority above 50 or email will never get sent.
99, 4
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment