wp_generate_user_request_key

函数


wp_generate_user_request_key ( $request_id )
参数
  • (int)
    $request_id
    Request ID.
    Required:
返回值
  • (string) Confirmation key.
定义位置
  • wp-includes/user.php
    , line 4794
引入
4.9.6
弃用

返回一个用户动作的确认密钥,并存储散列版本以便将来比较。

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 ),
		)
	);

	return $key;
}