WordPress Reference
-
General WordPress
- How to change the WordPress sender e-mail address without a plugin?
- How to completely disable WordPress comments
- How to create a WordPress menu logout link that bypasses the "are you sure you want to log out" message
- How to get rid of the “Sorry, this file type is not permitted for security reasons” when uploading to WordPress
- How to get rid of the error message "Too many failed login attempts. Please try again in..." if the WP Limit Login Attempts plugin is not installed
- How to hide PHP Warnings in WordPress
- How to redirect all the pages from an old domain to the homepage of a new domain
- MAMP: How to get rid of the error message "The link you followed has expired" when attempting to upload a WordPress theme
-
WordPress Themes
-
- Extra Theme - How to change body link color
- Extra Theme - How to change the widget title background color
- Extra Theme - How to remove the credits from the bottom footer
- Extra Theme - How to remove the Previous and Next navigation on all posts
- Sabai Discuss Q & A: How to style the Question Page in Divi Builder
-
WordPress Plugins
- How to add a "display current date" capability to a WordPress theme
- SiteGround Optimizer Plugin, SiteGround Security Plugin and the JNews Import Demo & Style process
-
- BuddyPress: How to hide profile Export Data link
- BuddyPress: How to hide the WordPress top admin bar for Logged Out users
- BuddyPress: How to remove the setting Profile Visibility
- How to change the default BuddyPress profile landing tab
- How to disable BuddyPress Public Message Button
- How to remove the BuddyPress profile ‘last active’ status
- Why create a BuddyPress bp-custom.php file?
-
- Directories Pro Demo
- Directories Pro documentation
- Directories Pro Documentation - Reviews
- Directories Pro: How to create a directories homepage like the Demo
- Directories Pro: How to put elements like Opening Hours, etc. in the sidebar like the demo
- Directories Pro: How to use views to display directory content
-
- Elementor Blog
- Elementor Integration with Adanced Custom Fields
- Elementor Knowledge base and help center
- Elementor: How do I learn about Flexbox Containers?
- How to Create a Custom Author Archive Page in Elementor
- How to use Elementor with Advanced Custom Fields Tutorial
- What is the Elementor Theme Builder?
-
- Articles coming soon
< All Topics
Print
How to create a WordPress menu logout link that bypasses the “are you sure you want to log out” message
Posted
Updated
Bynetpressionist
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
Table of Contents