Description
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
The following would apply 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. (format: gform_multifile_upload_field_FORMID)
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. (format: gform_multifile_upload_field_FORMID_FIELDID)
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.
Example(s)
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; }
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms Version 2.2.2.
Source Code
This filter is located in GFAsyncUpload::upload in gravityforms/upload.php.