Codex

Function Reference/wp generate password

Contents

Description

Generates a random password drawn from the defined set of characters.

Parameters

$len
(integer) (Optional) The length of the password to generate.
Default: 12
$special_chars
(boolean) (Optional) Whether to include standard special characters.
Default: true
$extra_special_chars
(boolean) (Optional) Whether to include other special characters. Used when generating secret keys and salts.
Default: false

Return values

(string) 
The random password.

Usage

<?php wp_generate_password(); ?>

Examples

<?php
  
echo 'New password: 'wp_generate_password();
?>

Notes

This function executes the random_password filter after generating the password.

Change Log

  • Since: 2.5