Skip to content

Instantly share code, notes, and snippets.

View matthewsuan's full-sized avatar

Matthew Suan matthewsuan

View GitHub Profile
@matthewsuan
matthewsuan / dont-delete-private-files.php
Created May 8, 2017 11:43 — forked from Shelob9/dont-delete-private-files.php
One way to prevent files, uploaded through Caldera Forms file fields, not set to be added to media library, from being deleted.
<?php
/** Wait until caldera_forms_core_init hook so we know all actions were added **/
add_action( 'caldera_forms_core_init', function() {
//File delete is attempted first here, but if an email should send, the file isn't deleted//
remove_action( 'caldera_forms_submit_complete', array( 'Caldera_Forms_Files', 'cleanup' ) );
//If email is set to be used, we wait until email is sent to delete on these hooks:
remove_action( 'caldera_forms_mailer_complete', array( 'Caldera_Forms_Files', 'delete_after_mail' ), 10, 3 );
remove_action( 'caldera_forms_mailer_failed', array( 'Caldera_Forms_Files', 'delete_after_mail' ), 10, 3 );