Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_generate_password [ WordPress Function ]

wp_generate_password ( $length = 12, $special_chars = true, $extra_special_chars = false )
Parameters:
  • (int) $length The length of password to generate
  • (bool) $special_chars Whether to include standard special characters. Default true.
  • (bool) $extra_special_chars Whether to include other special characters. Used when generating secret keys and salts. Default false.
Returns:
  • (string) The random password
Defined at:



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

Source


<?php
function wp_generate_password$length 12$special_chars true$extra_special_chars false ) {
    
$chars 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    if ( 
$special_chars )
        
$chars .= '!@#$%^&*()';
    if ( 
$extra_special_chars )
        
$chars .= '-_ []{}<>~`+=,.;:/?|';

    
$password '';
    for ( 
$i 0$i $length$i++ ) {
        
$password .= substr($charswp_rand(0strlen($chars) - 1), 1);
    }

    
// random_password filter was previously in random_password function which was deprecated
    
return apply_filters('random_password'$password);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics