Hello,
Please, how can I enforce the user to enter a strong password as a pre-requisite upon registration? Although the site shows that the password is "weak", it allows the user to complete the registration process. Is it possible without additional plugins?
Thank you.
Rgds
Rodrigo
Hi Logan,
Thank you your answer.
In order to avoid installing another plugin, I've implemented the code you suggested on the link and it worked perfectly, but only in the SIGNUP step! If you are already registered and try to redefine your password, the code doesn't prevent weak passwords anymore!! Do you know how add this restriction to password redefinitions?
Thank you again.
Rgds,
Rodrigo
try this:
function lehelmatyus_validation123() {
global $bp;
if ( !empty( $_POST['pass1'] ) )
if ( !valid_pass( $_POST['pass1'] ) ){
$bp->signup->errors['pass1'] = __( 'Your password is not strong enough. It needs to be at least 8 characters long, and must contain at least: 1 lowercase character (a-z), 1 uppercase character (A-Z), 1 number (0-9) and 1 special character (!@#..)', 'buddypress' );
}
}
add_action( 'bp_core_general_settings_after_submit', 'lehelmatyus_validation123');
function valid_pass($candidate) {
$r1='/[A-Z]/'; //Uppercase
$r2='/[a-z]/'; //lowercase
$r3='/[!@#$%^&*()-_=+{};:,<.>]/'; // whatever you mean by special char
$r4='/[0-9]/'; //numbers
if(preg_match_all($r1,$candidate, $o)<1) return FALSE;
if(preg_match_all($r2,$candidate, $o)<1) return FALSE;
if(preg_match_all($r3,$candidate, $o)<1) return FALSE;
if(preg_match_all($r4,$candidate, $o)<1) return FALSE;
if(strlen($candidate)<8) return FALSE;
return TRUE;
}
but it is not tested. it may not work. you should use third party plugin thats best way to achieve this.