Modify form data before it is processed

In this guide we will create a PHP function that will alter the values of two of the form fields before the form is processed. We will modify the values of two Text fields to set the value to uppercase.

Add the following code to the WordPress theme functions.php file (or create a plugin for it).

1234
5
678
9
10
11
add_filter('quform_pre_process_1', function (array $result) {    if (isset($_POST['quform_1_3'])) {        $_POST['quform_1_3'] = strtoupper($_POST['quform_1_3']);    }
 
    if (isset($_POST['quform_1_4'])) {        $_POST['quform_1_4'] = strtoupper($_POST['quform_1_4']);    }
 
    return $result;
});
add_filter('quform_pre_process_1', function (array $result) {
    if (isset($_POST['quform_1_3'])) {
        $_POST['quform_1_3'] = strtoupper($_POST['quform_1_3']);
    }

    if (isset($_POST['quform_1_4'])) {
        $_POST['quform_1_4'] = strtoupper($_POST['quform_1_4']);
    }

    return $result;
});
  • On line 1, replace the number 1 with the form ID
  • On lines 2 and 3, replace the three occurrences of 1_3 with the first Text element unique ID
  • On lines 6 and 7, replace the three occurrences of 1_4 with the second Text element unique ID
Be inspired. © 2018 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy