Using Gravity Forms ‘gform_payment_details’ PHP filter

The gform_payment_details is an action in Gravity Forms which is triggered after the payment details are shown within a Gravity Forms entry.

Usage

To utilize this action, you would use the add_action function in WordPress, specifying gform_payment_details as the action you want to hook into. Here’s a basic template for how you might use this:

function custom_gform_action($form_id, $entry) {
    // your custom code here
    return $form_id;
}
add_action('gform_payment_details', 'custom_gform_action', 10, 2);

Parameters

  • $form_id (integer): This is the ID of the form that is currently being processed.
  • $entry (array): This is the array that contains all the information about the current form entry.

More information

See Gravity Forms Docs: gform_payment_details

This action hook is located in entry_detail.php. It is available since Gravity Forms version 1.9.3. At the time of writing, it has not been deprecated.

Examples

Logging form ID

A common use for this action might be logging the form ID for debugging purposes. Here’s how you could do this:

function log_form_id($form_id, $entry) {
    error_log("Form ID: " . $form_id);
}
add_action('gform_payment_details', 'log_form_id', 10, 2);

Modifying Entry Data

You can use this hook to modify the entry data. Below, we will update the entry’s status:

function modify_entry_data($form_id, $entry) {
    $entry['status'] = 'complete';
}
add_action('gform_payment_details', 'modify_entry_data', 10, 2);

Sending a Confirmation Email

Perhaps you want to send a confirmation email when the payment details are displayed. Here’s how you could accomplish that:

function send_confirmation_email($form_id, $entry) {
    $to = $entry['3']; // assuming email is field 3
    $subject = 'Confirmation of Your Submission';
    $message = 'Thank you for your submission!';
    wp_mail($to, $subject, $message);
}
add_action('gform_payment_details', 'send_confirmation_email', 10, 2);

Adding a Custom Note

You might want to add a custom note to the entry. This can be accomplished as follows:

function add_custom_note($form_id, $entry) {
    $note = 'Payment details have been displayed.';
    GFFormsModel::add_note($entry['id'], $form_id, 0, $note);
}
add_action('gform_payment_details', 'add_custom_note', 10, 2);

Redirecting the User

Finally, you might want to redirect the user to a custom page after they view the payment details. Here’s how you could accomplish that:

function redirect_user($form_id, $entry) {
    $redirect_url = 'https://yourwebsite.com/thank-you';
    wp_redirect($redirect_url);
    exit;
}
add_action('gform_payment_details', 'redirect_user', 10, 2);