Codex

Function Reference/wp verify nonce

Contents

Description

Verify that correct nonce was used with time limit.

Usage

<?php wp_verify_nonce$nonce$action ); ?>

Parameters

$nonce
(string) (required) Nonce that was used in the form to verify.
Default: None
$action
(string) (int) Should give context to what is taking place and be the same when nonce was created.
Default: -1

Return Values

mixed 
In case of failure, returns false.

Otherwise, returns an integer, with possible values of 1 or 2.

  • 1 indicates that the nonce has been generated in the past 12 hours or less.
  • 2 indicates that the nonce was generated between 12 and 24 hours ago.

Example

<?php $noncewp_create_nonce  ('my-nonce'); ?>
<a href='myplugin.php?_wpnonce=<?php echo $nonce ?>'> ...

<?php 
$nonce
=$_REQUEST['_wpnonce'];
if (! 
wp_verify_nonce($nonce'my-nonce') ) die('Security check'); 
?>

Source File

wp_verify_nonce is defined in wp-includes/pluggable.php

Related

Nonce Functions: wp_explain_nonce, wp_nonce_ays, wp_nonce_field, wp_nonce_url, wp_verify_nonce, wp_create_nonce, check_admin_referer, check_ajax_referer

See also

External Resources

See also index of Function Reference and index of Template Tags.
This page is marked as incomplete. You can help Codex by expanding it.