WordPress filter hook

wpcf7_upload_file_name

Fired by 3 WordPress plugins, running on 10.1M+ sites between them.

How to use wpcf7_upload_file_name

It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'wpcf7_upload_file_name', function( $filename, $name, $options ) {
	// Change $filename here.
	return $filename;
}, 10, 3 );

Argument names come from Contact Form 7's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

3 plugins that fire wpcf7_upload_file_name

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Contact Form 7 icon Contact Form 710+ million installs apply_filters( 'wpcf7_upload_file_name', $filename, $name, $options ) includes/file.php:57
  2. Drag and Drop Multiple File Upload for Contact Form 7 icon Drag and Drop Multiple File Upload for Contact Form 760,000+ installs apply_filters( 'wpcf7_upload_file_name', $filename, $file['name'] ) inc/dnd-upload-cf7.php:1189
  3. Images Optimize and Upload CF7 icon Images Optimize and Upload CF7700+ installs apply_filters( 'wpcf7_upload_file_name', $filename, $originalName ) admin/ajax.php:60

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.