Using Gravity Forms ‘gform_get_form_confirmation_filter’ PHP filter

The gform_get_form_confirmation_filter is a Gravity Forms PHP filter that allows you to modify the form confirmation text programmatically before it is displayed on the page. This filter is specifically for text confirmations.

Usage

To apply the filter to all forms, use the following code:

add_filter('gform_get_form_confirmation_filter', 'your_function_name', 10, 2);

To target a specific form, append the form ID to the hook name:

add_filter('gform_get_form_confirmation_filter_10', 'your_function_name', 10, 2);

Parameters

  • $progress_confirmation (string) – The confirmation text.
  • $form (Form Object) – The form currently being processed.

More information

See Gravity Forms Docs: gform_get_form_confirmation_filter

Use the gform_confirmation filter for filtering confirmations in general.

Examples

Change confirmation text for all forms

This example changes the confirmation text for all forms:

function modify_confirmation_text($progress_confirmation, $form) {
    // Modify the confirmation text
    $progress_confirmation = "Thank you for your submission!";
    return $progress_confirmation;
}
add_filter('gform_get_form_confirmation_filter', 'modify_confirmation_text', 10, 2);

Change confirmation text for a specific form

This example changes the confirmation text for form ID 10:

function modify_confirmation_text_for_form_10($progress_confirmation, $form) {
    // Modify the confirmation text
    $progress_confirmation = "Your form 10 submission is successful!";
    return $progress_confirmation;
}
add_filter('gform_get_form_confirmation_filter_10', 'modify_confirmation_text_for_form_10', 10, 2);

Display custom confirmation based on field value

This example shows a different confirmation message based on the value of field 3:

function display_custom_confirmation($progress_confirmation, $form) {
    // Get the value of field 3
    $field_value = rgpost("input_3");

    if ($field_value == "yes") {
        $progress_confirmation = "Thank you for saying YES!";
    } else {
        $progress_confirmation = "Thank you for your response!";
    }

    return $progress_confirmation;
}
add_filter('gform_get_form_confirmation_filter', 'display_custom_confirmation', 10, 2);

Display confirmation with submitted data

This example shows a confirmation message with the user’s submitted name from field 1:

function display_confirmation_with_name($progress_confirmation, $form) {
    // Get the submitted name
    $name = rgpost("input_1");

    // Modify the confirmation text
    $progress_confirmation = "Thank you, {$name}, for your submission!";

    return $progress_confirmation;
}
add_filter('gform_get_form_confirmation_filter', 'display_confirmation_with_name', 10, 2);

Conditional confirmation based on form ID

This example shows a different confirmation message based on the form ID:

function conditional_form_confirmation($progress_confirmation, $form) {
    // Check the form ID
    if ($form["id"] == 10) {
        $progress_confirmation = "Confirmation for form 10!";
    } elseif ($form["id"] == 20) {
        $progress_confirmation = "Confirmation for form 20!";
    } else {
        $progress_confirmation = "Default confirmation!";
    }

    return $progress_confirmation;
}
add_filter('gform_get_form_confirmation_filter', 'conditional_form_confirmation', 10, 2);