wp_generate_user_request_key

函数
wp_generate_user_request_key ( $request_id )
参数
  • (int) $request_id Request ID.
    Required:
返回值
  • (string) Confirmation key.
定义位置
相关方法
wp_validate_user_request_keywp_get_user_requestwp_create_user_requestwp_get_user_request_datawp_send_user_request
引入
4.9.6
弃用
-

wp_generate_user_request_key: 该函数生成一个唯一的密钥,用于识别用户导出或删除其个人数据的请求。该密钥存储在用户的元数据中,用于在导出或删除其数据之前确认用户的身份: 该函数将用户ID作为一个参数,并返回生成的密钥。

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常见问题

FAQs
查看更多 >