Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

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.