Complete the code to verify a nonce in WordPress.
if ( ! wp_verify_nonce( $_POST['[1]'], 'my_action' ) ) { wp_die( 'Security check failed' ); }
The nonce field name used in the form is 'my_nonce', so we verify it with the same key.
Complete the code to create a nonce field in a WordPress form.
<?php wp_nonce_field( '[1]', 'my_nonce' ); ?>
The action name 'my_action' should match the one used in wp_verify_nonce for verification.
Fix the error in the nonce verification code.
if ( ! wp_verify_nonce( $_POST['[1]'], 'save_post' ) ) { wp_die( 'Invalid nonce' ); }
The nonce field name must match the one used in the form, which is 'my_nonce'.
Fill both blanks to create and verify a nonce correctly.
<?php wp_nonce_field( '[1]', '[2]' ); ?> if ( ! wp_verify_nonce( $_POST['my_nonce'], '[3]' ) ) { wp_die( 'Nonce check failed' ); }
The action name 'update_data' is used to create and verify the nonce. The nonce field name is 'my_nonce'.
Fill all three blanks to properly create, check, and handle a nonce in WordPress.
<?php wp_nonce_field( '[1]', '[2]' ); ?> if ( ! isset( $_POST['[2]'] ) || ! wp_verify_nonce( $_POST['[2]'], '[1]' ) ) { wp_die( '[3]' ); }
The action name is 'delete_post', the nonce field name is 'delete_nonce', and the error message is 'Invalid nonce'.