Confirm password field

This guide will show you how to add a password confirmation field so that the form user must enter their password twice and they must match.

Confirm password field

Step 1

Add two Password elements to your form, if you haven’t done so already. One for the password and one for the password confirmation.

Step 2

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

123
4
5
6
7
8
add_filter('quform_element_valid_1_4', function ($valid, $value, Quform_Element_Password $element) {    if ($value != $element->getForm()->getValue('quform_1_3')) {        $element->addError('The passwords do not match');
        $valid = false;
    }
 
    return $valid;
}, 10, 3);
add_filter('quform_element_valid_1_4', function ($valid, $value, Quform_Element_Password $element) {
    if ($value != $element->getForm()->getValue('quform_1_3')) {
        $element->addError('The passwords do not match');
        $valid = false;
    }

    return $valid;
}, 10, 3);
  • On line 1, change 1_4 to the unique ID of the confirm password element
  • On line 2, change 1_3 to the unique ID of the first password element
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy