How to Add Confirm Password Field In WooCommerce Registration Page?

You have created a registration page for users to enter their information and create their account. It’s very necessary in most of the registration and sign-up processes to allow users set a new password for the account. As the contents of the password that the user is going to set are hidden, there are chances of mistakes. This can cause troubles for the user later if they try to login with the wrong password.

A confirm password field is a good idea to avoid this hassle. If you place a confirm password field in the registration page, users will not make any mistake while setting the password as both fields should match.

Today, we tell you a code below that you can add to your design and that will add a confirm password field below the password field in WooCommerce registration page. This will compare the two fields, i.e. the first password entry and the confirm password entry, and will proceed with the remaining registration process if both match. Use this code and save the users from making any mistakes while setting the password.

Add the below mentioned code in functions.php file of your theme.

// 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">
		<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'] ); ?>" />


Editorial Staff

ThemeLocation Provides Wordpress & Woocommerce development & Customization services. Have a Project? Contact To discuss

Leave a Reply

Your email address will not be published. Required fields are marked *