WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to verify that the nonce I created exists but for some reason it keeps returning false, why is this happening?

Creating my nonce:

<?php wp_nonce_field('test_slider_action','test_slider_options_nonce'); ?>

Verifying my nonce exists:

if($_POST && wp_verify_nonce($_REQUEST['test_slider_options_nonce']))
    echo "TEST";

if I dump my $_REQUEST I get the correct value, but if I dump my wp_verify_nonce it returns false. If it matters, both my $_POST check and form / nonce creation is on the same page. What else do I need to get it to verify?

share|improve this question
up vote 5 down vote accepted

You need to pass the action to check your nonce against, wp_verify_nonce has two parameters.

if($_POST && wp_verify_nonce($_REQUEST['test_slider_options_nonce'],'test_slider_action'))
    echo "TEST";
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.