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.

Not quite understanding Gform_after_submission

  1. I'm not quite sure I understand the process.

    I have a form which is gathering data to submit to a 3rd party database through an API. It is expecting a XML file. I have the url and a login and password for the 3rd party system to receive the XML.

    I'm not certain I understand what the exact process is with Gravity Forms.

    I have the form data. I know the field id of each field and the content.

    I'm assuming that in the confirmation tab, I select Redirect and include the url of the server.

    At what point is Gform_after_submission executing?

    This is the sample header:

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
    <AuthenticationHeader xmlns="http://services.ecashsoftware.com/leads">
    <Username>string</Username>
    <Password>string</Password>
    </AuthenticationHeader>
    </soap:Header>
    <soap:Body>
    <!-- Input Data -->
    </soap:Body>
    </soap:Envelope>

    I am developing the code in PHP to format the data into an xml file, but I"m not sure I understand the process that Gravity Forms uses.

    Posted 11 years ago on Wednesday March 13, 2013 | Permalink
  2. Moved to the regular support forums from pre-purchase.

    Posted 11 years ago on Wednesday March 13, 2013 | Permalink
  3. You would not use the confirmation redirect at all. The gform_after_submission hook will run your function behind the scenes. The confirmation setting is independent from that.

    You will write a PHP function to create your XML file, and you will hook that function to the gform_after_submission hook.

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    The code you add to functions.php will look something like this:

    [php]
    add_action('gform_after_submission', 'send_to_ecash', 10, 2);
    function send_to_ecash($entry, $form) {
        // create the XML file from all your submitted data
        // send the request maybe with WP_Http
        $request = new WP_Http();
    }

    All the code to create and send the request goes inside this 'send_to_ecash' function. It will be run after the form is submitted, entry is created and notifications are sent.

    Posted 11 years ago on Wednesday March 13, 2013 | Permalink
  4. Hi Chris,
    Thanks for replying on my post. Anyways, i've followed your instruction and applied it on my functions.php file. Supposed to be, this function would convert some form entries after submission to be converted on an XML file, but when I tested it out on my server, am receiving an.

    here's the code i've created:

    add_action('gform_after_submission', 'post_to_third_party', 10, 2);
    function post_to_third_party($entry, $form) {
        $xml = new DOMDucment("1.0");
    
    	$eCash = $xml -> createElement('eCash');
    	$stores = $xml -> createElement('stores');
    	$store = $xml -> createElement('store');
    
    	$xml -> appendChild($eCash);
    	$eCash -> appendChild($stores);
    	$stores -> appendChild($store)
    	$store -> appendChild ($firstN);
    	$store -> appendChild ($lastN);
    	$store -> appendChild ($add);
    	$store -> appendChild ($city);
    	$store -> appendChild ($state);
    	$store -> appendChild ($email);
    	$store -> appendChild ($zip);
    	$store -> appendChild ($phone);
    	$store -> appendChild ($fax);
    
    		$firstN = $xml -> createElement('firstName', $entry['2.3']);
    		$lastN = $xml -> createElement('lastName', $entry['2.6']);
    		$add = $xml -> createElement('address', $entry['5.1']);
    		$city = $xml -> createElement('city', $entry['5.5']);
    		$state = $xml -> createElement('state', $entry['5.4']);
    		$email = $xml -> createElement('email', $entry['13.4']);
    		$zip = $xml -> createElement('zip', $entry['5.5']);
    		$phone = $xml -> createElement('phone', $entry['9']);		
    
    	header('content-type: text/xml');
    	$xml->save("formEntries.xml");
    	$request = new WP_Http();
    }
    Posted 11 years ago on Wednesday March 13, 2013 | Permalink
  5. Am receiving what? Maybe something was removed from your post? This is all I see to indicate that you might be having a problem: "am receiving an." What is happening?

    Posted 11 years ago on Thursday March 14, 2013 | Permalink