The gform_delete_entries action is triggered when entries are deleted in Gravity Forms, allowing further actions to be performed.
Usage
add_action('gform_delete_entries', 'my_function', 10, 2);
Parameters
- $form_id: The ID of the form that an entry is being deleted from.
- $status: The status of the deleted entry.
More information
See Gravity Forms Docs: gform_delete_entries
Examples
Display a message when an entry is deleted
This example displays a message when an entry is deleted from a form.
function my_function($form_id, $status) {
    echo 'Entry with status ' . $status . ' is being deleted from form ' . $form_id;
}
add_action('gform_delete_entries', 'my_function', 10, 2);
Log entry deletions
This example logs the deletion of entries in a custom log file.
function log_entry_deletion($form_id, $status) {
    $log_message = 'Entry with status ' . $status . ' was deleted from form ' . $form_id;
    error_log($log_message, 3, 'gravityforms_entry_deletions.log');
}
add_action('gform_delete_entries', 'log_entry_deletion', 10, 2);
Send an email when an entry is deleted
This example sends an email to the site administrator when an entry is deleted.
function email_on_entry_delete($form_id, $status) {
    $subject = 'Entry Deleted';
    $message = 'An entry with status ' . $status . ' was deleted from form ' . $form_id;
    wp_mail(get_bloginfo('admin_email'), $subject, $message);
}
add_action('gform_delete_entries', 'email_on_entry_delete', 10, 2);
Update a counter for deleted entries
This example updates a counter in the WordPress options when an entry is deleted.
function update_deleted_entries_counter($form_id, $status) {
    $counter = get_option('deleted_entries_counter', 0);
    $counter++;
    update_option('deleted_entries_counter', $counter);
}
add_action('gform_delete_entries', 'update_deleted_entries_counter', 10, 2);
Perform custom action based on the entry’s status
This example performs a custom action based on the status of the deleted entry.
function custom_action_on_entry_delete($form_id, $status) {
    if ($status === 'spam') {
        // Your custom code for handling spam entry deletions
    } elseif ($status === 'trash') {
        // Your custom code for handling trashed entry deletions
    }
}
add_action('gform_delete_entries', 'custom_action_on_entry_delete', 10, 2);