The gform_multifile_upload_field filter in Gravity Forms is used to filter the field object that will be associated with the uploaded file. This is useful when you want to use Gravity Forms upload system to upload files. Using this filter, you can return a one-time-use field object to process the file as desired.
Usage
To apply the filter to all forms:
add_filter('gform_multifile_upload_field', 'your_function_name', 10, 3);
To target a specific form, append the form id to the hook name:
add_filter('gform_multifile_upload_field_21', 'your_function_name', 10, 3);
To target a specific form and field, append the form id and field id to the hook name:
add_filter('gform_multifile_upload_field_21_3', 'your_function_name', 10, 3);
Parameters
$field
(Field Object) – The current field.$form
(Form Object) – The current form.$field_id
(int) – The current field id.
More information
See Gravity Forms Docs: gform_multifile_upload_field
Place your code snippet in the functions.php
file of your active theme.
This filter was added in Gravity Forms Version 2.2.2.
Examples
Create a custom file upload field
This example demonstrates how to create a custom file upload field that allows only CSV files.
add_filter('gform_multifile_upload_field', 'create_custom_file_upload_field', 10, 3); function create_custom_file_upload_field($field, $form, $field_id) { $field = new GF_Field_FileUpload(array( 'id' => $field_id, 'multipleFiles' => true, 'maxFiles' => 1, 'maxFileSize' => '', 'allowedExtensions' => 'csv' )); return $field; }