Generate a random password function

By using this code snippet you can generate a random password with in this example has 8 letters. It chooses all letters randomly from the $chars variable.

/**
 * Snippet Name: Generate a random password function
 * Snippet URL: https://www.wpcustoms.net/snippets/generate-random-password-function/
 */
  function random_password( $length = 8 ) {
    $chars = "[email protected]#$%^&*()_-=+;:,.?";
    $password = substr( str_shuffle( $chars ), 0, $length );
    return $password;
} 

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x