Answer the question
In order to leave comments, you need to log in
Why doesn't wp_verify_nonce() work from within a function?
I'm creating a link with wp_nonce in the GET parameter:
$link = esc_url( wp_nonce_url( add_query_arg( 'my_arg', 1 ) , 'product_subscription' ) );
echo '<a href="'. $link .'">'. $link .'</a>';
if(isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'product_subscription' ) ) {
echo "Nonce verified";
}
function check_subscription() {
echo "check_subscription";
if(isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'product_subscription' ) ) {
echo "Nonce verified";
}
}
Answer the question
In order to leave comments, you need to log in
Try to see the results:
echo $_GET['_wpnonce'];
echo wp_verify_nonce( $_GET['_wpnonce'], 'product_subscription' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question