The gform_payment_date Gravity Forms PHP filter allows you to modify the payment date displayed for the entry in the Payment Details section.
Usage
add_filter('gform_payment_date', 'your_function_name', 10, 3);
Parameters
- $payment_date (string): The payment date for the entry.
- $form (Form Object): The form.
- $entry (Entry Object): The entry.
More information
See Gravity Forms Docs: gform_payment_date
Examples
Change date format to year/day/month
In this example, the payment date format is changed to year/day/month.
add_filter('gform_payment_date', 'change_payment_date', 10, 3); function change_payment_date($payment_date, $form, $entry){ // Change date format to year/day/month $payment_date = GFCommon::format_date($payment_date, false, 'Y/d/m', $entry['transaction_type'] != 2); return $payment_date; }
Add a specific number of days to the payment date
In this example, 5 days are added to the payment date.
add_filter('gform_payment_date', 'add_days_to_payment_date', 10, 3); function add_days_to_payment_date($payment_date, $form, $entry){ $date = new DateTime($payment_date); $date->modify('+5 days'); $new_payment_date = $date->format('Y-m-d H:i:s'); return $new_payment_date; }
Set the payment date to a fixed date
In this example, the payment date is set to a fixed date (2023-05-01).
add_filter('gform_payment_date', 'set_fixed_payment_date', 10, 3); function set_fixed_payment_date($payment_date, $form, $entry){ $fixed_date = '2023-05-01'; return $fixed_date; }
Conditionally modify the payment date based on form ID
In this example, the payment date is modified only for a specific form with the ID 5.
add_filter('gform_payment_date', 'conditionally_modify_payment_date', 10, 3); function conditionally_modify_payment_date($payment_date, $form, $entry){ if ($form['id'] == 5) { $date = new DateTime($payment_date); $date->modify('+7 days'); $new_payment_date = $date->format('Y-m-d H:i:s'); return $new_payment_date; } return $payment_date; }
Display payment date in a custom format
In this example, the payment date is displayed in a custom format with the day of the week.
add_filter('gform_payment_date', 'display_custom_payment_date', 10, 3); function display_custom_payment_date($payment_date, $form, $entry){ $date = new DateTime($payment_date); $custom_format = $date->format('l, F j, Y'); return $custom_format; }