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.

Trouble with POST data using gform_after_submission

  1. dfeeley
    Member

    Greetings,

    I am attempting to use the gform_after_submission to post the results of a form to a 3rd party site. I have followed the examples from http://www.gravityhelp.com/documentation/page/Gform_after_submission and combined it with some outside support on the topic that I found here http://www.0to5blog.com/creative/gravity-forms-submitting-forms-to-3rd-party-applications/. And of course I am having trouble.

    I have been able to verify that I can post to the 3rd party site and submit the data to their forms using a command-line "http-ping" tool passing the same parameters as the gform_after_submission should be passing. So the 3rd party site appears to be ready.

    I used this same function to have the system email me the form IDs so that I would have them accurately. Here were my results of the Form IDs

    Array
    (
    [1] => dan
        [2] => feeley
        [3] => dan(at)extremefitnessmartialarts.com
        [4] => (203)555-1212
        [5] => Mon
        [6] => 10AM
        [8] => 1403
        [9] => redirectpagehere
        [10] => 0
        [7] =>
    )

    I then created these functions and added them to my functions.php file as suggested in the working examples of http://www.gravityhelp.com/documentation/page/Gform_after_submission

    Here are my functions:

    add_action('gform_after_submission_23', 'post_to_third_party', 10, 2);
    function post_to_third_party($entry, $form) {
    
        $post_url = 'https://addmembers.com/RainMaker/process/';
        $body = array(
     "SID" =>       $entry["8"],
     "EMail" =>     $entry["3"],
     "ReturnURL" =>  $entry["9"],
     "formID" =>    $entry["10"],
     "FName" =>     $entry["1"],
     "LName" =>     $entry["2"],
     "Phone" =>     $entry["4"]
            );
    
        $request = new WP_Http();
        $response = $request->post($post_url, array('body' => $body));
    
    }

    I limited it to happen on Gform 23, and also without the specific form ID number. Either way I do not get a post to the 3rd party system. So I am stumped. I am not a developer by any means, but I can certainly follow good instructions which these examples have. Can you spot anything obvious with this?

    Is there a way to have Gforms go into a debug mode, or log what its doing to better troubleshoot?

    Any assistance here is greatly appreciated!

    Posted 11 years ago on Wednesday June 12, 2013 | Permalink
  2. dfeeley
    Member

    OK. Call off the dogs. I don't know what I did to fix it, but I quadruple-checked everything and in my efforts of trying to see what was wrong, its now working. Maybe testing at 1AM in the morning had something to do with it! :)

    So as far as I know the above code is working. I have even been able to toggle the submission now by adding another Gform field called "sendTo3rdParty" and I can use the same function but control which forms are sent to the 3rd party directly on the form.

    Thanks for being there!

    Posted 11 years ago on Wednesday June 12, 2013 | Permalink
  3. David Peralty

    Glad you were able to figure it out. I took a quick look and didn't see anything wrong with what you posted, and was waiting to hear back if I was missing something. All my best!

    Posted 11 years ago on Wednesday June 12, 2013 | Permalink