This tutorial explains how to use submitted “File Name” metadata as the “File name” that is displayed on the “Edit Media” screen in the metadata panel (see screenshot below). Note that this technique affects the file-name metadata specifically; it does not change the actual name of the submitted file.

USP Pro - Custom Metadata for File Name

Shown above is the metadata panel for files displayed on the Edit Media screen. By default, WordPress uses the actual name of the uploaded file for this information. But with USP Pro, you can add custom metadata to each submitted file.

Once your form includes a “File Name” field, the submitted file-name information can be used for the metadata panel on the Edit Media screen. To make it happen, just add the following code snippet to your theme’s functions.php file:

function usp_custom_metadata_filename($name) {
	global $post;
	
	if (is_object($post)) $name = $post->post_name;
	
	return $name; // submitted via "File Name" field
}
add_filter('get_attached_file', 'usp_custom_metadata_filename', 10, 1);

After this function passes the custom file name via the get_attached_file hook, WordPress sanitizes the data using esc_html(), so there is no need to do any extra sanitizing beforehand.

Note that you can use $post->post_name elsewhere in your theme to display custom File Name information as desired.

So to recap: to display custom metadata for the File Name of submitted files, add the File Name field to your USP Form, and then include the above function in your theme.