Change WooCommerce default password security level

2019-01-19 06:15发布

问题:

I am trying to change the WooCommerce Registration form minimum password strength and I am unable to do much.

Can anyone please share a solution by which I can amend the minimum password strength and allow users to user a password that's 7 characters long and does not need any symbols or capital letters inside it?

Thanks.

回答1:

The only existing hook setting for that is woocommerce_min_password_strength filter hook. So you can set a custom hook function and lowering this strenght. There is 4 possible settings:

  • 3 => Strong (default)
  • 2 => Medium
  • 1 => Weak
  • 0 => Very Weak (anything).

Here is that code:

add_filter( 'woocommerce_min_password_strength', 'reduce_min_strength_password_requirement' );
function reduce_min_strength_password_requirement( $strength ) {
    // 3 => Strong (default) | 2 => Medium | 1 => Weak | 0 => Very Weak (anything).
    return 2; 
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This code is tested and works.

All other solutions will be complicated and a real development.



回答2:

FYI, that code did not work for me to lower the password requirements. I tried a couple other codes but to no avail. I ended up using this code below to simply remove the password requirement check.

function iconic_remove_password_strength() {
    wp_dequeue_script( 'wc-password-strength-meter' );
}
add_action( 'wp_print_scripts', 'iconic_remove_password_strength', 10 );

Taken from here: https://iconicwp.com/blog/disable-password-strength-meter-woocommerce/