Remove Password Strength Rules in WooCommerce Checkout

You can remove the password strength rules in WooCommerce checkout page when signing up for an account password, obviously this is less secure but may lessen cart abandonment by your customers – I have a few sites whereby this is a pain point for users.

woocommerce-password-strength

This snippet from @WPprodigy will take the strength-o-meter policy away

function wc_ninja_remove_password_strength() {
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
wp_dequeue_script( 'wc-password-strength-meter' );
}
}
add_action( 'wp_print_scripts', 'wc_ninja_remove_password_strength', 100 );
view raw functions.php hosted with ❤ by GitHub

Add in Password Confirmation Field

confirm-password-field

Another request I have had from some users is to bring back a second password field that validates the input they used in the first field.

<?php
// place the following code in your theme's functions.php file
// Add a second password field to the checkout page.
add_action( 'woocommerce_checkout_init', 'wc_add_confirm_password_checkout', 10, 1 );
function wc_add_confirm_password_checkout( $checkout ) {
if ( get_option( 'woocommerce_registration_generate_password' ) == 'no' ) {
$checkout->checkout_fields['account']['account_password2'] = array(
'type' => 'password',
'label' => __( 'Confirm password', 'woocommerce' ),
'required' => true,
'placeholder' => _x( 'Confirm Password', 'placeholder', 'woocommerce' )
);
}
}
// Check the password and confirm password fields match before allow checkout to proceed.
add_action( 'woocommerce_after_checkout_validation', 'wc_check_confirm_password_matches_checkout', 10, 2 );
function wc_check_confirm_password_matches_checkout( $posted ) {
$checkout = WC()->checkout;
if ( ! is_user_logged_in() && ( $checkout->must_create_account || ! empty( $posted['createaccount'] ) ) ) {
if ( strcmp( $posted['account_password'], $posted['account_password2'] ) !== 0 ) {
wc_add_notice( __( 'Passwords do not match.', 'woocommerce' ), 'error' );
}
}
}

 

ref

 

1 Comment

  1. niki on November 10, 2016 at 8:03 pm

    Is there any way to do this, but rather than allowing incredibly simple passwords – you can choose a more moderate password?

Leave a Comment





%d bloggers like this: