Skip to content

Instantly share code, notes, and snippets.

@hykw
Created September 4, 2014 06:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hykw/65fb50edf11edf1cd9bc to your computer and use it in GitHub Desktop.
Save hykw/65fb50edf11edf1cd9bc to your computer and use it in GitHub Desktop.
wordpress: nonce
$nonce = wp_nonce_field('pagename', '_wpnonce', true, false);
<form>
{$nonce}
</form>
---------------------
if(is_page('pagename') && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'pagename')) {
#
} else {
wp_redirect('/originalpage', 301);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment