Using Gravity Forms ‘gform_card_details’ PHP filter

The gform_card_details filter allows you to modify the “Card Details” label when creating a Stripe Card or Square field in Gravity Forms.

Usage

add_filter('gform_card_details', 'change_details', 10, 2);

Parameters

  • $label (string): The label to be filtered.
  • $form_id (integer): The current form’s ID.

More information

See Gravity Forms Docs: gform_card_details

Examples

Change the default “Card Details” label

This example changes the default “Card Details” label to “Credit Card Specifics”:

add_filter('gform_card_details', 'change_details', 10, 2);

function change_details($label, $form_id) {
    return "Credit Card Specifics";
}

Modify “Card Details” label based on form ID

This example changes the “Card Details” label based on the form ID:

add_filter('gform_card_details', 'change_details_by_form', 10, 2);

function change_details_by_form($label, $form_id) {
    if ($form_id == 1) {
        return "Credit Card Information";
    } elseif ($form_id == 2) {
        return "Payment Details";
    } else {
        return $label;
    }
}

Add a prefix to the “Card Details” label

This example adds a prefix to the “Card Details” label:

add_filter('gform_card_details', 'add_prefix', 10, 2);

function add_prefix($label, $form_id) {
    return "Secure: " . $label;
}

Add a suffix to the “Card Details” label

This example adds a suffix to the “Card Details” label:

add_filter('gform_card_details', 'add_suffix', 10, 2);

function add_suffix($label, $form_id) {
    return $label . " (SSL Encrypted)";
}

Remove the “Card Details” label

This example removes the “Card Details” label entirely:

add_filter('gform_card_details', 'remove_label', 10, 2);

function remove_label($label, $form_id) {
    return "";
}