I should also add that wordpress is configured for multisite.
Functions.php
Only works with Newest Registered.
// Force Strong Username
function strong_username() {
global $bp;
if ( !empty( $_POST['signup_username'] ) )
if ( !valid_username( $_POST['signup_username'] ) ){
$bp->signup->errors['signup_username'] = __( 'Your username is too weak or short. Please, use uppercase, lowercase and numbers.', 'bp-strong-username-password', 'buddypress' );
}
}
add_action( 'bp_signup_validate', 'strong_username');
function valid_username($candidate) {
$r1='/[A-Z]/'; //Uppercase
$r2='/[a-z]/'; //lowercase
$r3='/[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(strlen($candidate)<8) return FALSE;
return TRUE;
}
// Force Strong Password
function strong_validation() {
global $bp;
if ( !empty( $_POST['signup_password'] ) )
if ( !valid_pass( $_POST['signup_password'] ) ){
$bp->signup->errors['signup_password'] = __( 'Your password is too weak or short. Please, use uppercase, lowercase, numbers and special characters.', 'bp-strong-username-password', 'buddypress' );
}
}
add_action( 'bp_signup_validate', 'strong_validation');
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)<10) return FALSE;
return TRUE;
}