I've created a multi page webform and I want to run a function after the user clicks the 'Next page' button on the first page only. After the user fills in the data on the first page, I want to grab that data and do stuff with it. After that the webform should work like normal on through the submission process.

How can I do this so that the function runs only once? I've tried using hook_form_alter and testing the value of $form['details']['page_num']['#value']. This value is 2 if I'm on the second page. For some reason the function fires twice and I can't figure out why.


2 Answers 2


One way to accomplish this task, because the webform module is so complex, is to just use jQuery and attach to that button and node id and run an AJAX query or whatever else you want to do like redirect the user away and then back.

Otherwise you would probably be neck deep in a custom module that extends Webform. In my experience to alter webform modules becomes a major pain and I generally just go another route.

  1. Add a custom submit handler
  2. Call it in your submit handler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.