WordPress: verificare che la password di un utente sia robusta
In WordPress possiamo verificare che la password scelta da un utente sia robusta.
Possiamo creare la seguente funzione di utility.
function my_is_password_strong( $password, $min_length ) {
$uppercase = preg_match( '@[A-Z]@', $password );
$lowercase = preg_match( '@[a-z]@', $password );
$number = preg_match( '@[0-9]@', $password );
$special_chars = preg_match( '@[^\w]@', $password );
return ( $uppercase && $lowercase && $number && $special_chars && strlen( $password ) >= $min_length );
}