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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.