如何调整WordPress重置密码页面的密码强度为中等?
Hey Daniel, let’s tackle this password strength issue on your reset password page— I’ve been there too, so I know how frustrating it can be when hooks don’t seem to cooperate. The confusion between WordPress and WooCommerce makes total sense because both handle password checks, but we can target the right hooks to get this sorted.
First: Understand Who’s in Charge
- WordPress core manages the underlying password strength rules for all user accounts across the site.
- WooCommerce adds its own frontend checks to pages like reset password, my account, and checkout. So you might need to adjust either one or both depending on your needs.
Solutions to Try
1. Lower Password Strength Site-Wide (WordPress + WooCommerce)
If you want to weaken the password requirement everywhere—including admin user creation, reset pages, and WooCommerce frontend—use WordPress’s core password_strength filter. Add this code to your theme’s functions.php file or a custom plugin:
add_filter( 'password_strength', 'custom_lower_password_strength', 10, 3 ); function custom_lower_password_strength( $strength, $password, $user_id ) { // Default strength ranges from 0 (weakest) to 3 (strongest) return 0; // Adjust this number to your desired strength level }
2. Target Only WooCommerce Frontend Pages (Including Reset Password)
WooCommerce has a dedicated filter that affects only its frontend password checks—this is ideal if you don’t want to weaken admin-side password rules. Add this snippet:
add_filter( 'woocommerce_min_password_strength', 'custom_woocommerce_min_password_strength' ); function custom_woocommerce_min_password_strength() { // Set to 0 for no strength requirement, 1 for weak, 2 for medium, 3 for strong return 0; }
3. Completely Disable WooCommerce Password Strength Checks
If you want to remove the password strength meter and requirements entirely from WooCommerce pages (including reset password), use this filter:
add_filter( 'woocommerce_check_password_strength', '__return_empty_array' );
Why Your Previous Attempts Might Have Failed
- Wrong Hook Priority: If another plugin or theme is modifying the same hook, try increasing your filter’s priority (e.g., change
10to99) to ensure your code overrides default settings. - Editing Core Files: Never edit WordPress or WooCommerce core files—changes will get overwritten on updates. Always use a child theme’s
functions.phpor a custom plugin. - Cache Issues: After adding the code, clear your browser, plugin, and server cache to make sure the changes take effect.
Test the reset password flow after adding any of these snippets—you should see the password strength requirements reduced or removed entirely.
内容的提问来源于stack exchange,提问作者Daniel long

