Saving metabox updates causing fatal error

You are getting that fatal error because your custom mdb_save_metaboxes function is expecting to receive 3 parameters (function mdb_save_metaboxes($post_id, $post, $update)), but WordPress only passed 1 parameter, because you did not tell WordPress that it needs to pass 3 parameters. So to fix the issue, set the fourth parameter for add_action() like so: // If … Read more

Logout button in menu without “wp” in links

You can use wp_logout_url() function for logout link. It will automatically add nonce to the url. Try this code: add_action(‘template_redirect’, function() { if (empty($_SERVER[‘REQUEST_URI’])) return; $uri = $_SERVER[‘REQUEST_URI’]; if (preg_match(‘#^/log-out/?$#’, $uri, $matches) === 1) { $logout_url = str_replace(‘&’, ‘&’, wp_logout_url()); wp_safe_redirect($logout_url); die; } }); If you do not want to use wp_logout_url(), then try to … Read more

WordPress wp_localize_script nonce and ajax URL

wp_localize_script() doesn’t care much which script handle you use as long as it is a valid one. You could use your theme’s or Elementor’s main script handle with the function to make the data available for your script. You’ll need to check your theme’s or Elementors source coude to find what these handles are. Side … Read more

Nonce check causing issues when creating new post

I know that this is not the only tutorial that has code that check nonce for meta boxes but this is truly idiotic. Nonce should be checked per the whole action not per parts of it and if your save_post hook was called it means that the save nonce was already checked and found valid, … Read more

Metabox nonce not allowing update

The issue was that you should have changed product_noncename to goal_info_meta_box_nonce. I’ve also made a few other changes, commenting out the old lines for comparison, which should avoid any further errors (including the undefined index). // verify nonce // if ( ! isset( $_POST[‘product_noncename’] ) || ! wp_verify_nonce( $_POST[‘goal_info_meta_box_nonce’], basename( __file__ ) ) ) { … Read more

Using Nonce for my Form

I figured out what I needed to do. I needed if(isset( $_POST[ ‘tdgmt_plugin_noncename’]) && wp_verify_nonce( $_POST[‘tdgmt_plugin_noncename’], plugins_url( __FILE__))){ to be above if($screen->base == ‘settings_page_tgdmt_options_page’){ as well as fixing my typos of tdgmt_plugin_noncename instead of tgdmt_plugin_noncename