Using Gravity Forms ‘gform_paypal_return_url’ PHP filter

The gform_paypal_return_url filter allows you to modify the return URL, which is the URL that users will be sent to after completing the payment on PayPal’s site. This can be useful when the return URL isn’t created correctly (could happen on some server configurations using PROXY servers).

Usage

add_filter('gform_paypal_return_url', 'your_function_name', 10, 4);

Parameters

  • $url (string) – The return URL, uses the $_SERVER['SERVER_NAME'] parameter.
  • $form_id (integer) – The ID of the form being processed.
  • $entry_id (integer) – The ID of the entry being processed.
  • $query (string) – The gf_paypal_return parameter and value.

More information

See Gravity Forms Docs: gform_paypal_return_url

Examples

Use site_url()

This example shows how you can replace the default return URL with the URL returned by the WordPress site_url function.

add_filter('gform_paypal_return_url', 'update_url', 10, 4);

function update_url($url, $form_id, $entry_id, $query) {
    return trailingslashit(site_url()) . '?' . $query;
}

Hardcoded URL

This example shows how you can replace the default return URL with a hardcoded URL.

add_filter('gform_paypal_return_url', 'update_url', 10, 4);

function update_url($url, $form_id, $entry_id, $query) {
    return 'https://somedomain.com/?' . $query;
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

apply_filters('gform_paypal_return_url', $url, $form_id, $lead_id, $query)

This filter is located in GFPayPal::return_url() in class-gf-paypal.php.