Home › Forums › Quform WordPress › passing variables from one form to another
- This topic has 5 replies, 2 voices, and was last updated 8 years, 4 months ago by patdundee.
- AuthorPosts
- December 13, 2015 at 9:16 am #17651patdundeeParticipant
Hi Guys
On my site I have a form which also using WP custom fields, with hidden fields in the form set as the relevant parameter names, and uses the redirect to another page. Using a child theme I capture all the elements that are sent via the post action.What I would like to try and add to this functionality is the ability to pass variables to a different form located on another page and auto fill elements on the new form with the value that is passed from the previous form.
For example:
Someone wishes to pay a deposit on an item, rather than pay in full. (This selection is made via radio buttons) The price and product code and passed to the functions php in the child theme. I need to be able to pass the price and the product code to the relevant hidden elements on the form on the new page.I then need it to auto set the values in three of the fields in the new form. 2 of these fields are drop down select and the third is preset value depending on the selections made in the drop down values of field 1 and 2
Is there a way this can be achieved please.
Many thanks
PDecember 13, 2015 at 1:29 pm #17654patdundeeParticipantAs a change to the above (which should make it easier to work out)
I do already catch these variables and they are saved in their own session names, which i prefer as the variables and their values do not show in the url when redirecting.
So all i need to do is find a way to make the value of the hidden fields = the value of the sessions.
input type="hidden" name="iphorm id" value="php session"
Can this be achieved?
Many thanks
PDecember 14, 2015 at 12:25 pm #17670AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 14, 2015 at 2:39 pm #17674patdundeeParticipantHi Ally
It is not filling in the value. I have told the page to print the session to the screen so I can see that the session is live and has a value.
Here is what I have put in the functions php
function my_pre_display($form)
{
$form->setValue('iphorm_2_57', $wp_session['sku']);
}
add_action('iphorm_pre_display_2', 'my_pre_display');
The element 2_57 is also a hidden one
PDecember 14, 2015 at 2:51 pm #17678AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 14, 2015 at 3:00 pm #17679patdundeeParticipantHi Ally
setting global inside the function did not work but doing it this way doesfunction my_pre_display($form) { $wp_session = WP_Session::get_instance(); $form->setValue('iphorm_2_57', $wp_session['sku']); } add_action('iphorm_pre_display_2', 'my_pre_display');
P
- This reply was modified 8 years, 4 months ago by patdundee.
- AuthorPosts
- You must be logged in to reply to this topic.