The gform_payment_status Gravity Forms PHP filter allows you to modify the payment status displayed for the entry in the Payment Details section.
Usage
add_filter('gform_payment_status', 'your_function_name', 10, 3);
Parameters
- $payment_status (string): The payment status for the entry.
- $form (Form Object): The form.
- $entry (Entry Object): The entry.
More information
See Gravity Forms Docs: gform_payment_status
Examples
Change payment status from ‘Processing’ to ‘Testing’
add_filter('gform_payment_status', 'change_payment_status', 10, 3); function change_payment_status($payment_status, $form, $entry){ if ($payment_status == 'Processing'){ $payment_status = 'Testing'; } return $payment_status; }
Set payment status to ‘Failed’ if a specific field value is not met
add_filter('gform_payment_status', 'check_field_value', 10, 3); function check_field_value($payment_status, $form, $entry){ $required_value = 'example_value'; if ($entry['2'] != $required_value){ $payment_status = 'Failed'; } return $payment_status; }
Set payment status to ‘Refunded’ based on a custom date
add_filter('gform_payment_status', 'refund_payment_after_date', 10, 3); function refund_payment_after_date($payment_status, $form, $entry){ $refund_date = strtotime('2023-05-01'); if (strtotime($entry['date_created']) < $refund_date){ $payment_status = 'Refunded'; } return $payment_status; }
Set payment status to ‘Pending’ if total amount is less than $10
add_filter('gform_payment_status', 'set_pending_for_low_amount', 10, 3); function set_pending_for_low_amount($payment_status, $form, $entry){ if ($entry['payment_amount'] < 10){ $payment_status = 'Pending'; } return $payment_status; }
Set payment status based on user role
add_filter('gform_payment_status', 'change_status_based_on_role', 10, 3); function change_status_based_on_role($payment_status, $form, $entry){ $user = get_userdata($entry['created_by']); if (in_array('administrator', $user->roles)){ $payment_status = 'Completed'; } return $payment_status; }