Can’t change upload folder
-
Hi,
i try change upload files outside media library, to directory for example ‘form-uploads’. Checkboxes Attach to Mailer, Allow Multiple and Add to Media Library are off. I have functions.php in child-theme, field_id copy from actual form.
I created directory form-uploads in /wp-content/uploads/form-uploads and set chmod 777.Url added file from mail is still
https://prototyp.zsto.cz/wp-content/uploads/f1f15d409e4e5e53e773a84e80673769/test-pdf-1.pdf and file isn’t here.my code from functions.php:
add_filter( ‘caldera_forms_upload_directory’, function( $dir, $field_id ){
if( ‘fld_1720034’ == $field_id ){
$dir = ‘form-uploads’;
}
return $dir;
}, 20, 2 );/** 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 );//Just in case of a never completed submission or some other issue, a CRON job is used to delete the file
remove_all_actions( Caldera_Forms_Files::CRON_ACTION );});
Thank you for any help
The page I need help with: [log in to see the link]
- The topic ‘Can’t change upload folder’ is closed to new replies.