Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce 2.1 Add confirm password field on My Account register form
<?php
// 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'] ); ?>" />
</p>
<?php
}
?>
@MEGGAWORLD

This comment has been minimized.

Copy link

@MEGGAWORLD MEGGAWORLD commented Feb 14, 2016

Hello there,

Your code was very helpful, nevertheless i'm having an issue when loggin out of the account i get a blank page: http://www.membership.megga.be/my-account/
Any idea how to solve this?

Regards,
Louis

@anandgmtk

This comment has been minimized.

Copy link

@anandgmtk anandgmtk commented Jun 1, 2016

account register page redirect but the password was not reset

@vikasnautane

This comment has been minimized.

Copy link

@vikasnautane vikasnautane commented Apr 7, 2017

thnx its work for me..

@xbass540

This comment has been minimized.

Copy link

@xbass540 xbass540 commented Apr 27, 2017

hi,
i found this code very helpfull but my customer complains that it requires very strong passwords. Is there a way to lower the level of security?
thanks

@tinhochu

This comment has been minimized.

Copy link

@tinhochu tinhochu commented Jun 7, 2017

Very useful man thanks!

@Atif0007

This comment has been minimized.

Copy link

@Atif0007 Atif0007 commented Oct 23, 2017

Its work but the possition at the down how can i move it to password the 2nd password... please help...

@pinksharpii

This comment has been minimized.

Copy link

@pinksharpii pinksharpii commented May 10, 2018

The validation message shows up at the top which is great but the field is still outlined in green, not red. Is there a way to mark the field as invalid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.