gform_plupload_settings

Description

The filter gform_pluploads_settings allows the initialization settings (file size, file count, browse button, drag and drop, and more) for Plupload to be changed. Plupload is used when the allow multiple files option is enabled.

Usage

The following would apply to all forms.

add_filter( 'gform_plupload_settings', 'your_function_name', 10, 3 );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_plupload_settings_FORMID)

add_filter( 'gform_plupload_settings_75', 'init_plupload_settings', 10, 3 );

Parameters

An array of the current settings for Plupload.

The ID of the form in use.

The field object.

Examples

1. Maximum File Size

add_filter( 'gform_plupload_settings', 'init_plupload_settings', 10, 3 );
function init_plupload_settings( $settings, $form_id, $field ){
$settings['filters']['max_file_size'] = '100kb';
return $settings;
}

2. The uploader URL

add_filter( 'gform_plupload_settings', function( $settings, $form_id, $field ){
$settings['url'] = trailingslashit( site_url() ) . '?gf_page=' . GFCommon::get_upload_page_slug();
return $settings;
}, 10, 3 );

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in GF_Field_FileUpload::get_field_input() in includes/fields/class-gf-field-fileupload.php.