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;