Description
Filter the renamed filename.
Usage
Apply to all fields and forms.
add_filter( 'gpfr_filename', 'my_custom_function', 10, 3 );
Apply to all fields on a specific form.
add_filter( 'gpfr_filename_FORMID', 'my_custom_function', 10, 3 );
Apply to a specific field on a specific form.
add_filter( 'gpfr_filename_FORMID_FIELDID', 'my_custom_function', 10, 3 );
Parameters
renamed_file string
Renamed filename.
file string
The original filename.
entry object
The properties of the entry including field values.
Examples
Global Filename Template
<?php
/**
* Gravity Perks // GP File Renamer // Global Filename Template
* https://gravitywiz.com/documentation/gravity-forms-file-renamer/
*
* This snippet puts all files in an entry-specific subfolder and increments the filename with its count.
*/
add_filter( 'gpfr_filename', function( $renamed_file, $file, $entry ) {
$renamed_file = gp_file_renamer()->rename_file( $file, '{entry:id}/{filename}-{i}', $entry );
return $renamed_file;
}, 10, 3 );
Lowercase All Filenames
<?php
/**
* Gravity Perks // GP File Renamer // Lowercase All Filenames
* https://gravitywiz.com/documentation/gravity-forms-file-renamer/
*
* This snippet will automatically lowercase all filenames.
*/
add_filter( 'gpfr_filename', function( $renamed_file, $file, $entry ) {
return strtolower( $renamed_file );
}, 10, 3 );
Since
This filter is available since Gravity Forms File Renamer 1.0.