PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

gform after submission not working

  1. I have a form that needs to be posted to third party. The code appears to be ignored. Here is the code I added to bottom of functions.php

    add_action('gform_after_submission_4', 'post_to_third_party', 10, 2);
    function post_to_third_party($entry, $form) {
    
        $post_url = 'third party url here. real url removed for security';
        $body = array(
            'CustomFields[40]' => $entry['input_1'], // first name
            'CustomFields[41]' => $entry['input_2'], // last name
            'CustomFields[44]' => $entry['input_3'], // organization name
            'CustomFields[42]' => $entry['input_4'], // phone
            'email' => $entry['input_5']  // email
            );
    
        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));

    The form has been setup on this page http://dev10.swd.ca/resources/articles/

    Please advise. Thank you.

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  2. David Peralty

    Can I have you try http://www.gravityhelp.com/documentation/page/Gform_post_submission instead of after_submission and let me know if it works for you?

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  3. You mean simply changing
    gform_after_submission to gform_post_submission

    and leave everything else as is? I tried this and it does not work.

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  4. David Peralty

    I don't see anything wrong with your code. Can you send me an admin login for your WP site so I can check out your functions.php file for myself? Or you can send the file to peralty@rocketgenius.com

    Either way, there is no reason this should be skipped over.

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  5. David Peralty

    Can you just have the input id's just be their numbers and see if that works (1) instead of (input_1)?

    Are you getting any data on the receiving end? Can I have you try a print_r($_POST); on the receiving end?

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  6. Not working at all. If it was, a page redirect should occur.

    If there was bad data being posted, I would be redirected to an error page.

    I have the html version here http://dev10.swd.ca/test.htm and it works just fine.

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  7. David Peralty

    It won't redirect because it is calling the page via CURL. Hence the word Request. Basically you are pushing data to a third party page through POST, not controlling the page you send a user to.

    The hook has to be called for Gravity Forms to work correctly. If you want to redirect a user after the form has been submitted, you wouldn't use this hook.

    If you want to redirect to another page, and send data via Query String, you can do that from the form settings. Click on the form title and go to Confirmation. Change it to URL and then enable Query Strings.

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  8. I did not know this feature existed. My searches on your site always showed I should use gform after submission.

    The html version of the form does not post a query string. I tried your method and I am getting results. I get an error page that indicates bad email address. You can do a test submit to see result.

    Thank you.

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  9. David Peralty

    Yeah, the issue is probably that the @ symbol is being passed as %40. You'll have to edit what is receiving the data using urldecode(); http://ca2.php.net/manual/en/function.urldecode.php

    Posted 12 years ago on Monday May 28, 2012 | Permalink
  10. hacked the code on the other end and now it works a treat :)

    Thank you.

    Posted 12 years ago on Tuesday May 29, 2012 | Permalink
  11. David Peralty

    Glad to hear it. :)

    Posted 12 years ago on Tuesday May 29, 2012 | Permalink

This topic has been resolved and has been closed to new replies.