WordPress nonce not working
-
<?php /** * Template Name: Manage Days */ if ( isset($_GET['remove_date']) && isset($_GET['_wpnonce']) ) { $delete_date = $_GET['remove_date']; $delete_nonce = $_GET['_wpnonce']; if ( ! wp_verify_nonce( $delete_nonce, 'holiday_nonce' ) ) { die( 'Failed security check' ); } else { $delete_holiday = $wpdb->delete( $wpdb->prefix . 'ab_holidays', [ 'staff_id' => $staff_id, 'date' => $delete_date ], [ '%d', '%s' ] ); } } get_header(); ?> <?php $disable_dates = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}ab_holidays WHERE staff_id = '$staff_id'"); foreach ( $disable_dates as $disable_date ) { $originalDate = $disable_date->date; $newDate = date("F j, Y", strtotime($originalDate)); $nonce = wp_create_nonce( 'holiday_nonce' . $originalDate ); echo '<a href="' . get_permalink() . '?remove_date=' . $originalDate . '&_wpnonce=' . $nonce . '" class="delete-holiday"><i class="fa fa-times-circle"></i></a>' . $newDate . '<br />'; } ?> <?php get_footer();if ( ! wp_verify_nonce( $delete_nonce, ‘holiday_nonce’ ) ) { …. } else { ….. }
The blockquote code not working….
-
Hi there,
Can you please tell us the URL or website address which you need help with and also tell us more about your question?
That can help us to answer your question. -
Hi again,
It looks like you need help with WordPress open source project which is available at WordPress.org.
Can you please try seeking help at WordPress.org Forum here:
https://wordpress.org/supportThis Forum is dedicated to sites build on WordPress.com,
WordPress.com and WordPress.org are two different version of WordPress, learn more about there differences here: https://en.support.wordpress.com/com-vs-org/I have also found documentation on WordPress.org please visit
https://codex.wordpress.org/WordPress_NoncesAnd for further questions relating to the self-hosted site please try seeking help at WordPress.org Forum:https://wordpress.org/support
Hope this helps! Thanks!
- The topic ‘WordPress nonce not working’ is closed to new replies.