Allows the array of entry IDs to be modified before automatically deleting entries according to the personal data retention policy.


add_filter( 'gform_entry_ids_automatic_deletion', 'your_function_name', 10, 1 );


  • $entry_ids array

    The array of entry IDs to delete.


Delete only entries in Trash

The following example shows how to limit entry deletion to entries in Trash. The example limits its scope to form id 74.

add_filter( 'gform_entry_ids_automatic_deletion', 'save_entries', 10, 1 );
function save_entries( $entry_ids ){
	$delete_ids = array();
	foreach ( $entry_ids as $entry_id )
		$entry = GFFormsModel::get_entry( $entry_id );
		//save entries for form id 74 that are not in the trash
		if ( ! $entry['form_id'] == 74 || $entry['status'] == 'trash' ){
			$delete_ids[] = $entry_id;
			GFCommon::log_debug( 'Deleting entry ' . $entry['id'] );
			GFCommon::log_debug( 'Not deleting entry ' . $entry['id'] );
	return $delete_ids;

Remove one entry from the deletion list

The following example shows how to remove an entry from the list of entries to be deleted.

add_filter( 'gform_entry_ids_automatic_deletion', function( $entry_ids ) {
	GFCommon::log_debug( '(): Excluding an entry from the deletion list.' );
	// Remove entry ID 99 from the deletion list.
	unset( $entry_ids['99'] );
	return $entry_ids;
} );


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


This filter was added in Gravity Forms version 2.4.

Source Code

This filter is located in GF_Personal_Data::cron_task() in includes/class-personal-data.php.