Using Gravity Forms ‘gform_card_security_code’ PHP filter

The gform_card_security_code filter allows you to modify the “Security Code” label when creating a credit card field in Gravity Forms.

Usage

add_filter('gform_card_security_code', 'change_security_code', 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_security_code

Examples

Change Security Code label

This example changes the default “Security Code” label to “CVV Code”:

function change_security_code($label, $form_id) {
    return "CVV Code";
}
add_filter('gform_card_security_code', 'change_security_code', 10, 2);

Change Security Code label based on form ID

This example changes the “Security Code” label to “CVV Code” only for form ID 5:

function change_security_code_for_form($label, $form_id) {
    if ($form_id == 5) {
        return "CVV Code";
    }
    return $label;
}
add_filter('gform_card_security_code', 'change_security_code_for_form', 10, 2);

Change Security Code label to include a hint

This example changes the “Security Code” label to include a hint for users:

function add_hint_to_security_code($label, $form_id) {
    return "Security Code (3 digits on back)";
}
add_filter('gform_card_security_code', 'add_hint_to_security_code', 10, 2);

Make Security Code label uppercase

This example changes the “Security Code” label to be in uppercase:

function uppercase_security_code($label, $form_id) {
    return strtoupper($label);
}
add_filter('gform_card_security_code', 'uppercase_security_code', 10, 2);

Append additional text to Security Code label

This example appends additional text to the “Security Code” label:

function append_text_to_security_code($label, $form_id) {
    return $label . " (required)";
}
add_filter('gform_card_security_code', 'append_text_to_security_code', 10, 2);