返回用户操作的确认密钥,并存储散列版本以供将来比较。
原型
wp_generate_user_request_key( int $request_id )
参数
$request_id
(int)
(Required)
请求ID。
返回值
(string)
确认密钥。
源文件
路径:wp-includes/user.php
<?php
...
function wp_generate_user_request_key( $request_id ) {
global $wp_hasher;
// Generate something random for a confirmation key.
$key = wp_generate_password( 20, false );
// Return the key, hashed.
if ( empty( $wp_hasher ) ) {
require_once ABSPATH . WPINC . '/class-phpass.php';
$wp_hasher = new PasswordHash( 8, true );
}
wp_update_post( array(
'ID' => $request_id,
'post_status' => 'request-pending',
'post_password' => $wp_hasher->HashPassword( $key ),
'post_modified' => current_time( 'mysql', false ),
'post_modified_gmt' => current_time( 'mysql', true ),
) );
return $key;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_generate_user_request_key/