Problem:
I want to upload multiple files (one repeating-field) via CRED-form.
After successfull uploads, i want to move and rename the files to a different file-directory (with a little bit php-code via the cred_submit_complete hook). Don´t want to use hooks like "wp_handle_upload_prefilter", "upload_dir", or "cred_form_ajax_upload_validate". After that i have to update the custom repeating field with the new renamed file-paths and file-names.
Unfortunatelly the upload-function by toolset will add the files to the media library automatically and i don´t want that.
So my two questions are
1. Is the hook the right place for renaming, moving and updating uploaded files?
2. How do i prefent to attach files to the media library?
Solution:
Q1) Is the hook the right place for renaming, moving and updating uploaded files?
Yes, I think it is the right place. And it is possible to use action hook "cred_submit_complete" to achieve what you want, for example when user submit the CRED form successfully, use action hook "cred_submit_complete" to trigger a custom PHP function, in this PHP function, get the file/image field value:
https://developer.wordpress.org/reference/functions/get_post_meta/
Then rename the file name to what you want:
http://php.net/manual/en/function.rename.php
Q2) How do i prevent to attach files to the media library?
You can simply remove it from medial library:
https://developer.wordpress.org/reference/functions/wp_delete_post/
For example, use action hook "cred_submit_complete" to trigger a custom PHP function, in this PHP function, get the file/image field value
https://developer.wordpress.org/reference/functions/get_post_meta/
get the post ID of file/image in media library:
https://pippinsplugins.com/retrieve-attachment-id-from-image-url/
Then remove it from media library:
https://developer.wordpress.org/reference/functions/wp_delete_post/
For your reference.
Relevant Documentation:
https://developer.wordpress.org/reference/functions/wp_delete_post/
https://developer.wordpress.org/reference/functions/get_post_meta/