Home › Forums › General Issues › Force an Image/File upload to a particular directory › Reply To: Force an Image/File upload to a particular directory
good question. I don’t think that hook will work because you can’t change the file name, only add errors for custom validation.
I would use the wp_handle_upload_prefilter hook.
Take a look in the file …/plugins/advanced-custom-fields-pro/includes/api/api-helpers.php
There is a function in there named get_source_field() that shows how ACF gets the field associated with the upload. I would do the same thing to determine if the upload is for an ACF field, what field, and then alter the file name if it’s the right field.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!