Last active
September 17, 2017 23:00
-
-
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/
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 | |
/** | |
* 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