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.