This hook can be used to alter the filename of a file when it is uploaded.
quform_upload_filename_X_X
This hook is run for a single element.
Example
12
3
4
5
| add_filter('quform_upload_filename_1_3', function ($filename, array $file, Quform_Element_File $element, Quform_Form $form) { $filename = 'my-new-filename'; return $filename; }, 10, 4); |
add_filter('quform_upload_filename_1_3', function ($filename, array $file, Quform_Element_File $element, Quform_Form $form) { $filename = 'my-new-filename'; return $filename; }, 10, 4);
- On line 1, replace
1_3
with the File Upload element unique ID
1
2
3
4
5
6
7 | function my_quform_upload_filename($filename, array $file, Quform_Element_File $element, Quform_Form $form) { $filename = 'my-new-filename'; return $filename; } add_filter('quform_upload_filename_1_3', 'my_quform_upload_filename', 10, 4); |
function my_quform_upload_filename($filename, array $file, Quform_Element_File $element, Quform_Form $form) { $filename = 'my-new-filename'; return $filename; } add_filter('quform_upload_filename_1_3', 'my_quform_upload_filename', 10, 4);
- On line 7, replace
1_3
with the File Upload element unique ID
Parameters
$filename
–string
– the current filename$file
–array
– the file data (see the File Upload element data type for example)$element
–Quform_Element_File
– the File Upload element instance$form
–Quform_Form
– the form instance