Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator threadi

    (@threadi)

    If you want to check the password complexity, it makes little sense to start with a password generation function. As you can see, this is also used by other components.

    Have a look at the hook check_passwords: https://developer.ww.wp.xz.cn/reference/hooks/check_passwords/

    Sometimes it is also worth to have a look at the source code of plugins that already implement this. E.g.: https://ww.wp.xz.cn/plugins/password-policy-manager/ or iThemeSecurity.

    Thread Starter gladsong

    (@gladsong)

    Hi,

    I’m not just trying to cehck the validity, I’m trying to generate the password according to my criteria, and have WP use it. For example when manually clicking on the “generate password” , or when the password field is auto-populated with a generated password.

    And, yep. I’ve looked at the code of every plugin I can get my hands on. Including iThemes. Huge overkill, and as far as I can tell they rip out the core stuff, and do lots their own way

    So, yes, I want several components to use ‘my’ intended password. I just need to understand how to NOT have other components use it, like that resetlink I mentioned above.

    Moderator threadi

    (@threadi)

    If you are concerned with clicking “generate password”, then you could set an AJAX request as a condition in your function. Because the click triggers exactly this. All functions that come to the filter “random_password” without AJAX would then remain unaffected by your function.

    Example:

    function my_random_password( $password, $length, $special_chars, $extra_special_chars ) {
       if( !defined('DOING_AJAX') ) {
        return $password;
       }
       // your function ..
       return $yourpassword;
    }
    add_filter('random_password', 'my_random_password', 99, 4);
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Change password reqts with NO plugin without breaking resetpass link?’ is closed to new replies.