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.

GET form field entries for use in PHP-function

  1. OK, I'm really stuck with something very simple (I guess) – I looked all over the place but couldn't find an answer.

    I want to re-write the confirmation-URL via gform_confirmation to dynamically build from the entries made:

    if($form["id"] == "1"){
            $confirmation = array('redirect' => 'https://billing.micropayment.de/ebank2pay/event/?' . 'firstname=' . $entry['1.3'] . '&' . 'lastname=' . $entry['1.4']  . '&' . 'email=' . $entry['1.2']  . '&project=rdstnz&title=Mitgliedsaccount-Er-distanziert-sich&amount=200');
        }

    All my $entry-calls are left blank upon confirmation/submission. How do I manage to get the field-values? Would you kindly provide a simple code to call upon a form entry? Then I could implement that one and move on...

    Thanks & sorry for my poor PHP-skills.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  2. If you are using the gform_confirmation filter, you should be using $lead, not $entry. Documentation: http://www.gravityhelp.com/documentation/page/Gform_confirmation

    If you need more help, please provide all the code, including the filter, here so we can see exactly how you're doing things.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  3. Hey Chris,

    thanks for your swift reply. I virtually found nothing on the use of $lead and am unsure if this will function for my case.

    Here goes my code:

    add_filter("gform_confirmation", "custom_confirmation", 10, 4);
    function custom_confirmation($confirmation, $form, $lead, $ajax){
    
    	$remember = $lead['1.3'];
    
    	if($form["id"] == "1"){
            $confirmation = print_r($remember);
        }
        else if($form["id"] == "101"){
            $confirmation = array('redirect' => 'https://billing.micropayment.de/ebank2pay/event/?' . 'firstname=' . $firstname . '&' . 'lastname=' . $entry['1.4']  . '&' . 'email=' . $entry['1.2']  . '&project=rdstnz&title=Mitgliedsaccount-Er-distanziert-sich&amount=200');
        }
    
        return $confirmation;
    }

    I use the first IF-condition to test/debug. The second one is what I am trying to accomplish: I need the $entries to be inserted into the URL-query.

    Thanks!

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  4. $lead and $entry are used nearly interchangeably. Just change $entry in your code to $lead, since $lead is what is passed to the gform_confirmation filter. I should not be able to see $entry in your code at all when you're done.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  5. OK, but even the first condition (see above, I used $lead instead of $entry) doesn't provide me with a correct output. All I get is "1" (don't know where that is coming from).

    I double-checked, that the confirmation-code is working correctly ($remember = 'SOME-TEXT-VALUE';). What am I doing wrong? What is the correct use of $lead? Or do I need to pull those values differently?

    Sorry for causing trouble, but I am simply stuck.

    Posted 11 years ago on Thursday January 17, 2013 | Permalink
  6. I dit it. Following is my solution to grab the values entered into the form and build a customized redirection-URL-array. Just check for the corresponding field-names ("input_X", provided by GF) in your HTML-output and enter those. You may not need to define the variables ($firstname = $_POST["input_3"];) like I did, but that's 'cleaner' IMHO.

    add_filter("gform_confirmation", "custom_confirmation", 10, 4);
    function custom_confirmation($confirmation, $form, $lead, $ajax){
    
    $firstname = $_POST["input_3"];
    $lastname = $_POST["input_4"];
    $email = $_POST["input_2"];
    
        if($form["id"] == "1"){
    		$confirmation = array('redirect' => 'https://billing.micropayment.de/ebank2pay/event/?' . 'firstname=' . $firstname . '&' . 'lastname=' . $lastname  . '&' . 'email=' . $email  . '&project=rdstnz&title=Mitgliedsaccount-Er-distanziert-sich&amount=200');
        }
    
        return $confirmation;
    }

    Thanks.

    Posted 11 years ago on Friday January 18, 2013 | Permalink
  7. Thanks for posting your solution here.

    Posted 11 years ago on Friday January 25, 2013 | Permalink

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