wp_nonce_url() WordPress Function

The wp_nonce_url() function is a security measure that generates a unique URL with a nonce (number used once) attached to it. This nonce is then checked when the user visits the URL to make sure that the request is valid and that the user has the necessary permissions.

wp_nonce_url( string $actionurl, int|string $action = -1, string $name = '_wpnonce' ) #

Retrieve URL with nonce added to URL query.


Parameters

$actionurl

(string)(Required)URL to add nonce action.

$action

(int|string)(Optional) Nonce action name.

Default value: -1

$name

(string)(Optional) Nonce name.

Default value: '_wpnonce'


Top ↑

Return

(string) Escaped URL with nonce action added.


Top ↑

Source

File: wp-includes/functions.php

function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) {
	$actionurl = str_replace( '&', '&', $actionurl );
	return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) );
}


Top ↑

Changelog

Changelog
VersionDescription
2.0.4Introduced.

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