Home › Forums › ACF PRO › Rename media filename during upload › Reply To: Rename media filename during upload
Solved.
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
needed to be assigned a priority of 11 or higher (since the WP default is 10).
So the following code now allows me to rename the filename of a media file uploaded through my some_file_upload
field, which is an ACF File Upload field:
// ACF Upload Prefilter:
add_filter('acf/upload_prefilter/name=some_file_upload', 'acf_upload_prefilter' );
function acf_upload_prefilter() {
// WP Handle Upload Prefilter:
add_filter('wp_handle_upload_prefilter', 'rename_current_acf_upload', 11, 1);
}
function rename_current_acf_upload( $file ){
$file['name'] = 'custom-filename-' . $file['name'];
return $file;
}
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!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.