Using Gravity Forms ‘gform_field_types_delete_files’ PHP filter

The gform_field_types_delete_files is a Gravity Forms filter that allows you to add additional field types for file deletion when file deletion occurs.


A generic example for 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);


  • $field_types (array) – Field types that contain file uploads.
  • $form (Form Object) – The current form.

More information

See Gravity Forms Docs: gform_field_types_delete_files


Prevent file deletion when entries are deleted

This code prevents files associated with entries from being deleted when entries are deleted.

add_filter('gform_field_types_delete_files', '__return_empty_array');

Add custom field type for file deletion

This example adds the post_custom_field to the field types for file deletion.

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