Skip to content

Instantly share code, notes, and snippets.

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/95b327db59de6a217bed7486ceaf803a to your computer and use it in GitHub Desktop.
Save Shelob9/95b327db59de6a217bed7486ceaf803a to your computer and use it in GitHub Desktop.
<?php
/**
* Delete one field's value after Caldera Forms sends main mailer
*/
add_action( 'caldera_forms_submit_complete',
function( $form, $referrer, $process_id, $entry_id ){
//IMPORTANT: Change form ID here
$form_id = 'CF123456';
//IMPORTANT: Change field ID here
$field_id = 'fld_8768091';
//Only run on this form
if( $form[ 'ID' ] == $form_id ){
//check if field is present in form
if( is_array( Caldera_Forms_Field_Util::get_field( $field_id, $form ) ) ){
//Delete just this one field's value
global $wpdb;
$wpdb->delete( $wpdb->prefix . 'cf_form_entry_values', array(
'entry_id' => $entry_id,
'field_id' => $field_id
) );
}
}
},
//Priority 26 is one higher than priority used to send main mailer
//If priority was 24, field would not be included in email
26,
//4 args needed so we can get entry ID
4
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment