The gform_paypal_request filter allows you to modify the URL string that will be sent to PayPal before the user is redirected to PayPal for payment.
Usage
add_filter('gform_paypal_request', 'your_function_name', 10, 5);
Parameters
- $url (string): The entire URL that will be sent to PayPal, including the query string.
- $form (Form Object): The Form Object of the entry created.
- $entry (Entry Object): The Entry Object created.
- $feed (Feed Object): The feed currently being processed.
- $submission_data (Submission Data): Contains the form title, payment amount, setup fee amount, trial amount, line items created using the submitted pricing field values, and any discounts from coupons.
More information
See Gravity Forms Docs: gform_paypal_request
Examples
Change Return URL
This example changes the “return” URL in the query string. This is where PayPal returns to after payment is made and should be your form.
add_filter('gform_paypal_request', 'update_url', 10, 3); function update_url($url, $form, $entry) { // Parse URL into its individual pieces (host, path, querystring, etc.) $url_array = parse_url($url); // Start rebuilding URL $new_url = $url_array['scheme'] . '://' . $url_array['host'] . $url_array['path'] . '?'; $query = $url_array['query']; // Get querystring // Parse querystring into pieces parse_str($query, $qs_param); $return = $qs_param['return']; // Return URL // Parse return URL so the querystring is left alone while modifying the URL $return_url = parse_url($return); // Rebuild URL with new location $new_return_url = $return_url['scheme'] . '://' . 'rocketgenius.com/contact-us/?' . $return_url['query']; $qs_param['return'] = $new_return_url; // Update return querystring parameter to new value $new_qs = http_build_query($qs_param); // Rebuild querystring $new_url .= $new_qs; // Add querystring to URL return $new_url; }