gform_field_types_delete_files

gform_field_types_delete_files

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
Allows additional files to be deleted when file deletion occurs by adding additional field types.
Usage
The following would apply to all forms.
1add_filter( 'gform_field_types_delete_files', 'your_function_name', 10, 2 );
To target a specific form, append the form id to the hook name. (format: gform_field_types_delete_files_FORMID)
1add_filter( 'gform_field_types_delete_files_1', 'your_function_name', 10, 2 );

Parameters

$field_types array
Field types which contain file uploads.

$form Form Object
The current form.

Examples
The following example will allow you to keep files associated to entries after deleting the entries.
1add_filter( 'gform_field_types_delete_files', '__return_empty_array' );
The following example adds the post_custom_field to the field types to be removed.
12345add_filter( 'gform_field_types_delete_files', 'delete_custom_field_upload' );        function delete_custom_field_upload( $field_types ) {            $field_types[] = 'post_custom_field';            return $field_types;        }
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 1.9.10.
Source Code
This filter is located in:

GFFormsModel::get_delete_file_field_types() in forms_model.php
GFFormsModel::get_delete_file_field_types() in forms_model_legacy.php

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注