看起来我是用这个类来做这个的:http://gravitywiz.com/rename-uploaded-files-for-gravity-form/ 并在207行之后添加了过滤器,即。
// replace merge tags
$form = GFAPI::get_form( $entry[\'form_id\'] );
$value = GFCommon::replace_variables( $value, $form, $entry, false, true, false, \'text\' );
// MOD: add a filter here to hook into filename change
$value = apply_filters(\'gravity_forms_upload_filename\', $value, $entry);
$value
然后将包含上载文件的完整路径,该文件可以挂接并压缩,以便您可以返回zip路径。
这是我用来加载的代码段GW_Rename_Uploaded_Files
:
add_action(\'init\', \'my_forms_rename_uploads\', 11);
if (!function_exists(\'my_forms_rename_uploads\')) {
function my_forms_rename_uploads() {
if (!class_exists(\'GW_Rename_Uploaded_Files\')) {return;}
$form_ids = array(
1, // list of form IDs to load renaming class for
);
// --- get all file upload fields ---
foreach ($form_ids as $form_id) {
$upload_field_ids = array();
$form = GFFormsModel::get_form_meta($form_id);
if (isset($form[\'fields\'])) {
// --- get upload field IDs ---
foreach ($form[\'fields\'] as $field) {
if ($field->type == \'fileupload\') {$upload_field_ids[] = $field->id;}
}
// --- set class arguments ---
$args = array(
\'form_id\' => $form_id,
\'field_id\' => $upload_field_ids,
\'template\' => \'{filename}\'
);
// --- initialize rename uploaded files class for fields ---
new GW_Rename_Uploaded_Files($args);
}
}
}
}
希望这有助于。。。