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!
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.