Clear session on Form load in a multipage form

I am in a scenario, where i want to clear session value on form load, if session value exists. So for this purpose I have used gform_loaded action. It is working fine but it gform_loaded is actually triggering on all pages.
I have a checkbox in form page 1. If checkbox is checked, i have set a value in session. If session value is set on step 1 then I need to have a value in session until form submission is complete. And if a users quits webpage before completing the form submission, so on next visit, session value shouldn’t exist for that user on step 1. For this purpose, I need to know any alternative action to gform_loaded which only triggers on Page 1 of the loaded form.


You can try gform_pre_render which runs before displaying the form and has access to the $form variable. This allows you to get the current page like:

$current_page = GFFormDisplay::get_current_page( $form['id'] );

I hope that helps!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.