Home > AI > Backend > Wordpress >

wp_verify_nonce

Example:

// create a nonce in a form
<form method="post">
   <!-- some inputs here ... -->
   <?php wp_nonce_field( 'name_of_my_action', 'name_of_nonce_field' ); ?>
</form>


// validate the nonce
if ( ! isset( $_POST['name_of_nonce_field'] ) 
    || ! wp_verify_nonce( $_POST['name_of_nonce_field'], 'name_of_my_action' ) 
) {
   print 'Sorry, your nonce did not verify.';
   exit;
} else {
   // process form data
}

Leave a Reply