1

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?

1 Answer 1

7

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";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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