The gform_card_expiration filter allows you to modify the “Expiration Date” label in Gravity Forms when creating a credit card field.
Usage
add_filter('gform_card_expiration', 'change_expiration', 10, 2); function change_expiration($label, $form_id) { // your custom code here return $label; }
Parameters
- $label (string): The “Expiration Date” label to be filtered.
- $form_id (integer): The current form’s ID.
More information
See Gravity Forms Docs: gform_card_expiration
Examples
Change “Expiration Date” label to “Expires”
Change the default “Expiration Date” label to “Expires”:
add_filter('gform_card_expiration', 'change_expiration', 10, 2); function change_expiration($label, $form_id) { return "Expires"; }
Change “Expiration Date” label to “Valid Thru”
Change the default “Expiration Date” label to “Valid Thru”:
add_filter('gform_card_expiration', 'change_valid_thru', 10, 2); function change_valid_thru($label, $form_id) { return "Valid Thru"; }
Change “Expiration Date” label based on form ID
Change the “Expiration Date” label based on a specific form ID:
add_filter('gform_card_expiration', 'change_expiration_for_form', 10, 2); function change_expiration_for_form($label, $form_id) { if ($form_id == 5) { return "Expires On"; } return $label; }
Change “Expiration Date” label to “Expiry Date”
Change the default “Expiration Date” label to “Expiry Date”:
add_filter('gform_card_expiration', 'change_expiry_date', 10, 2); function change_expiry_date($label, $form_id) { return "Expiry Date"; }
Add a custom prefix to the “Expiration Date” label
Add a custom prefix to the “Expiration Date” label:
add_filter('gform_card_expiration', 'add_prefix_to_expiration', 10, 2); function add_prefix_to_expiration($label, $form_id) { return "Card " . $label; }