We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22448
    • 241 Posts
    For SEO tracking reasons we could not use eform's ThankYou parameter and had to redirect eForm to another page using the &gotoid parameter. However on the new page there was another eForm asking the user to subscribe to the newsletter using their name and email, which were already submitted in the first form. It was awkward to have to ask the user to re-enter the same information again, it had to be pre-filled. Unfortunately, unlike the &thankyou template, eform does not pass any values to the &gotoid page. What to do?
    Here's the solution that i came up with. No warranties but it works for us.

    Create a new snippet "formHelper" or whatever you want to call it with this code:
    <?php
    function setSubscriber( &$fields ){
    	if (isset($fields['name'])) {
    		$_SESSION['subscriber_name'] = $fields['name'];
    	}
    	if (isset($fields['email'])) {
    		$_SESSION['subscriber_email'] = $fields['email'];
    	}
    	return true;
    }
    function getSubscriber( &$fields ){
    	if (isset($_SESSION['subscriber_name'])) {
    		$fields['name'] = trim($_SESSION['subscriber_name']);
    		$_SESSION['subscriber_name'] = '';
    	}
    	if (isset($_SESSION['subscriber_email'])) {
    		$fields['email'] = trim($_SESSION['subscriber_email']);
    		$_SESSION['subscriber_email'] = '';
    	}
    	return true;
    }
    return;
    ?>
    


    change the names of functions and variables to whatever you need.
    The setSubscriber function takes the values for the name and email from the initial form and saves them into the session variables.
    The getSubscriber function retrieves the subscriber's name and email and adds them into the fields array of the new eform. Then it clears the session variables.

    Add the following to the eform snippet call of the first form:

    &runSnippet=`formHelper` &eFormOnMailSent=`setSubscriber`


    Add this to the snippet call of the second form on the &gotoid page:

    &runSnippet=`formHelper` &eFormOnBeforeFormMerge=`getSubscriber`


    And finally change the form template of the second form to add the value attribute to the proper inputs:
    <input name="name" id="cfName" class="text" type="text" value="[+name+]" eform="Name::1" />
    <input name="email" id="cfEmail" class="text" type="text" value="[+email+]" eform="Email:email:1" />



    Now the name and email fields of the eform on the &gotoid page will be pre-filled with the correct values.