Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.