This is what worked for me. First I created a custom log out menu link like the one below. I named the link label “logout”
https://yoursite.com/wp-login.php?action=logout&redirect_to=https://yoursite.com
Then
I added the code below to my child theme’s functions.php file:
function change_menu($items){ foreach($items as $item){ if( $item->title == "logout"){ $item->url = $item->url . "&_wpnonce=" . wp_create_nonce( 'log-out' ); } } return $items; } add_filter('wp_nav_menu_objects', 'change_menu');
The above code adds the variable necessary to disable the message to the link labeled “logout”
Source: https://wordpress.stackexchange.com/questions/274257/using-nonce-in-menu-item
- netpressionist answered 1 year ago
- last edited 1 year ago
- You must login to post comments
Your Answer