WordPress nonce failed sometime
I have generated the nonce key in the HTML form using the following function – wp_nonce_field(‘test_form_action’, ‘test_form_field’); and posted all the form data along with nonce value to server side using ajax method
Server-side validation
if (!isset($_POST['test_form_field']) || !wp_verify_nonce($_POST['test_form_field'], 'test_form_action')) {
$response = array('error'=>'Server error. Please try again later','msg'=>'');
} else {
// Success
}
It works most of the time. But sometimes nonce verification failed
Error Log:
NOTICE: PHP message: Thu, 14 Oct 2020 21:04:44 +0000: Bad registration request. nonce verification failed. d26c88db67
And why that nonce thing is failed sometime? Can anyone guide me in the right direction What could be the issue?
Leave an answer
You must login or register to add a new answer .