If you want to add confirm field password field on the registration form under my account page, then this tutorial is specially designed for you. Please keep your close attention in this post and use the below code snippets.
Add the below code at the end of the functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | //Add the code below to your theme's functions.php file to add a confirm password field on the register form under My Accounts. add_filter('woocommerce_registration_errors', 'registration_errors_validation', 10,3); function registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) { global $woocommerce; extract( $_POST ); if ( strcmp( $password, $password2 ) !== 0 ) { return new WP_Error( 'registration-error', __( 'Passwords do not match.', 'woocommerce' ) ); } return $reg_errors; } add_action( 'woocommerce_register_form', 'wc_register_form_password_repeat' ); function wc_register_form_password_repeat() { ?> <p class="form-row form-row-wide confirm_password"> <label for="reg_password2"><?php _e( 'Password Repeat', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="password" class="input-text" name="password2" id="reg_password2" value="<?php if ( ! empty( $_POST['password2'] ) ) echo esc_attr( $_POST['password2'] ); ?>" required/> </p> <?php } |
After adding the code snippets in your functions.php file, register form will look like the screenshot.
Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: confirm password field in my account page, woocommerce plugin for wordpress tutorial, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners, wordpress tutorials for beginners, wordpress tutorils