The gform_pre_confirmation_deleted Gravity Forms PHP/JavaScript action event is triggered right before a form’s confirmation is deleted.
Usage
add_action('gform_pre_confirmation_deleted', 'my_function', 10, 2);
Parameters
- $confirmation_id (int) – The ID of the confirmation being deleted.
- $form (array) – The ID of the form that the confirmation is being deleted from.
More information
See Gravity Forms Docs: gform_pre_confirmation_deleted
This action hook is located in preview.php.
Examples
Log Confirmation Deletion
Log the deletion of a confirmation to a custom log file.
add_action('gform_pre_confirmation_deleted', 'log_confirmation_deletion', 10, 2);
function log_confirmation_deletion($confirmation_id, $form) {
// Log the confirmation deletion
$message = "Confirmation ID: {$confirmation_id} was deleted from form ID: {$form['id']}";
error_log($message, 3, 'confirmation_deletion.log');
}
Send Email Notification
Send an email notification to the site administrator when a confirmation is deleted.
add_action('gform_pre_confirmation_deleted', 'send_email_notification', 10, 2);
function send_email_notification($confirmation_id, $form) {
// Send an email notification to the site administrator
$to = get_option('admin_email');
$subject = 'Confirmation Deleted';
$message = "A confirmation with ID: {$confirmation_id} was deleted from form ID: {$form['id']}.";
wp_mail($to, $subject, $message);
}
Custom Deletion Message
Display a custom message to the user after a confirmation is deleted.
add_action('gform_pre_confirmation_deleted', 'custom_deletion_message', 10, 2);
function custom_deletion_message($confirmation_id, $form) {
// Set a custom deletion message
$_SESSION['custom_deletion_message'] = "The confirmation with ID: {$confirmation_id} was successfully deleted.";
}
Backup Confirmation Data
Backup confirmation data before it is deleted.
add_action('gform_pre_confirmation_deleted', 'backup_confirmation_data', 10, 2);
function backup_confirmation_data($confirmation_id, $form) {
// Backup confirmation data before deletion
$confirmation_data = GFAPI::get_confirmation($confirmation_id);
update_option("backup_confirmation_{$confirmation_id}", $confirmation_data);
}
Prevent Deletion of Specific Confirmation
Prevent deletion of a specific confirmation based on its ID.
add_action('gform_pre_confirmation_deleted', 'prevent_specific_confirmation_deletion', 10, 2);
function prevent_specific_confirmation_deletion($confirmation_id, $form) {
// Check if confirmation ID matches the one to be prevented
if ($confirmation_id == 123) {
wp_die('You are not allowed to delete this confirmation.');
}
}