WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/random password

Description

random_password filters the randomly generated password created during the wp_generate_password().

Parameters

$password
(string) (required) The generated password.
Default: None

Examples

The following example would do something for the name_of_function() function:

add_filter( 'random_password', 'my_random_password' );
function my_random_password() {
    $characters ='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    $length = 10;
    $password = '';
    for( $i = 0; $i < $length; $i++ ) {
        $password .= substr( $characters , wp_rand( 0, strlen( $characters ) - 1 ), 1 );
    }
    return $password;
}

Change Log

Since: 3.0

Source File

random_password is located in wp-includes/pluggable.php

Related