You can run your own custom code on the form values when the form is submitted by adding code to process.php. We have set aside two areas for you to do this before and after all other form processing has taken place. In process.php, search for these terms
// Custom code section #1
// Custom code section #2
You can add any code you like to either section. Below are examples of what you can do in each section. You have access to the form instance $form
and you can iterate through the form elements using the method $form->getElements()
. You can get specific element values using the code $form->getValue('unique_element_name');
.
Custom code section #1
In this section you can add further form validation before the rest of the process code is done. You can return from the process function, display an error to the form user and stop further processing. For example if you wanted to log a user into your website, you could use code similar to below.
1 2 3 4 5 6 7 | $username = $form->getValue('username'); $password = $form->getValue('password'); if (!login($username, $password)) { $form->setError('The username or password is incorrect'); return false; } |
$username = $form->getValue('username'); $password = $form->getValue('password'); if (!login($username, $password)) { $form->setError('The username or password is incorrect'); return false; }
Note: this is example code and will not actually work as a login system
Custom code section #2
In this section you can perform any further processing actions, for example saving the form data to your subscriber email list.