Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_verify_nonce [ WordPress Function ]

wp_verify_nonce ( $nonce, $action = -1 )
Parameters:
  • (string) $nonce Nonce that was used in the form to verify
  • (string|int) $action Should give context to what is taking place and be the same when nonce was created.
Returns:
  • (bool) Whether the nonce check passed or failed.
Defined at:



Verify that correct nonce was used with time limit.

The user is given an amount of time to use the token, so therefore, since the UID and $action remain the same, the independent variable is the time.

Source


<?php
function wp_verify_nonce($nonce$action = -1) {
    
$user wp_get_current_user();
    
$uid = (int) $user->ID;

    
$i wp_nonce_tick();

    
// Nonce generated 0-12 hours ago
    
if ( substr(wp_hash($i $action $uid'nonce'), -1210) == $nonce )
        return 
1;
    
// Nonce generated 12-24 hours ago
    
if ( substr(wp_hash(($i 1) . $action $uid'nonce'), -1210) == $nonce )
        return 
2;
    
// Invalid nonce
    
return false;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics