Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: PDF After Submission
- Description: Opens a PDF in a new tab after a Gravity Form is submitted for the resource custom post type.
- Version: 1.0
- Author: Your Name
- */
- // Hook to Gravity Form submission for form ID 25
- add_action('gform_after_submission_25', 'redirect_after_submission', 10, 2);
- function redirect_after_submission($entry, $form) {
- // Get the PDF URL from ACF field
- $pdf_url = get_field('resource_target', $entry['post_id']);
- // If PDF URL is valid
- if (!empty($pdf_url) && filter_var($pdf_url, FILTER_VALIDATE_URL) !== false) {
- // Define the custom thank you page URL
- $thank_you_url = home_url('/thank-you/');
- $redirect_url = add_query_arg('pdf_url', urlencode($pdf_url), $thank_you_url);
- wp_redirect($redirect_url);
- exit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment