Saturday, February 11, 2023
HomeWordPress Developmentpassword - 'random_password' filters not taking impact

password – ‘random_password’ filters not taking impact


I believe, your PHP syntax is flawed. Strive these,

perform wpgenerapass_generate_password( $password, $size, $special_chars, $extra_special_chars ) {
    $chars="abcdefghijklmnopqrstuvwxyz";
    $chars .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $chars .= '0123456789';
    $chars .= '!@#$%^&*()';
    
    if ( $extra_special_chars ) {
        $chars .= '-_ []{}<>~`+=,.;:/?|';
    }
    
    $wpgenerapass_password = ''; // Initialize the password string
    $password_length       = 8;
    
    for ( $i = 0; $i < $password_length; $i += 1 ) {
        $wpgenerapass_password .= substr( $chars, wp_rand( 0, strlen( $chars ) - 1 ), 1 );
    }
    
    return $wpgenerapass_password;
}

add_filter( 'random_password', 'wpgenerapass_generate_password', 99, 4 );

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments