gform_field_types_delete_files

Description

Allows additional files to be deleted when file deletion occurs by adding additional field types.

Usage

The following would apply to all forms.

add_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)

add_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.

add_filter( 'gform_field_types_delete_files', '__return_empty_array' );

The following example adds the post_custom_field to the field types to be removed.

add_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