wp_generate_user_request_key()WP 4.9.6

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

Хуков нет.

Возвращает

Строку. Confirmation key.

Использование

wp_generate_user_request_key( $request_id );
$request_id(int) (обязательный)
Request ID.

Заметки

  • Global. PasswordHash. $wp_hasher Portable PHP password hashing framework instance.

Список изменений

С версии 4.9.6 Введена.

Код wp_generate_user_request_key() WP 6.5.2

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;
}