• Hi,

    Is there a way of enforcing password complexity when allowing new users to create their own passwords on registration? I’ve looked through the documentation but haven’t been able to find anything.

    Many thanks for a great plugin.
    Captain Tancredi

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    There isn’t currently a built in method for this. However you can write your own field validation and hook it to the wpmem_pre_register_data action.

    http://rocketgeek.com/plugins/wp-members/docs/filter-hooks/wpmem_pre_register_data

    Thread Starter Captain Tancredi

    (@skaroth)

    Thanks Chad, I’ll have a look into how to do this.

    Thread Starter Captain Tancredi

    (@skaroth)

    Hi Chad,

    I think I have something (fairly basic) working now as below –

    add_action( 'wpmem_pre_register_data', 'my_reg_hook' );
     
    function my_reg_hook( $fields )
    {
        $pwd  = $fields['password'];
        $pwd2 = $fields['confirm_password'];
    
        if (!preg_match('#[a-zA-Z]+#', $pwd)) {
            $error = 'Password must include at least one letter!';
        }
    
        if (!preg_match('#[0-9]+#', $pwd)) {
            $error = 'Password must include at least one number!';
        }
    
        if (strlen($pwd) < 8) {
            $error = 'Password too short! Must be at least 8 characters.';
        }
    
        if ($pwd2 !== $pwd) {
            $error = 'Passwords do not match!';
        } 
    
        global $wpmem_themsg;
        $wpmem_themsg = $error;
    }
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Password Strength’ is closed to new replies.