wp_generate_user_request_key() WordPress Function

The wp_generate_user_request_key() function is used to generate a key for use in user request keys. User request keys are used to verify the identity of a user when making certain requests, such as password reset requests. This function takes a user ID as its only parameter.

wp_generate_user_request_key( int $request_id ) #

Returns a confirmation key for a user action and stores the hashed version for future comparison.


Parameters

$request_id

(int)(Required)Request ID.


Top ↑

Return

(string) Confirmation key.


Top ↑

Source

File: wp-includes/user.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 ),
		)
	);

	return $key;
}


Top ↑

Changelog

Changelog
VersionDescription
4.9.6Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More