Skip Navigation

[Resolved] Creating a logout link for menu item

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 3.26 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by Alok Sharma 2 years ago.

Assisted by: Jamal.



I want to add a logout link in the menu item.

If I add [wpv-logout-link] in the URL field, it doesn't work. And if I add /wp-login.php?action=logout&redirect_to=/my-account/ in the URL field, it does work, but it asks for the confirmation.

Is there anyway to create a logout link that logs out the user directly, without asking for their confirmation.




Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

By default, WordPress will not evaluate shortcodes inside the menus. Toolset does not actually have any effects on menus. However, you can run a shortcode inside a menu using a 3rd party plugin such as

You may also want to use a specialize plugin such as

I hope this helps. Let me know if you have any questions.


Hi Jamal,

For some reasons, the plugin didn't work for me. I did some research and came across a solution over here hidden link

* Generates custom logout URL
function getLogoutUrl($redirectUrl = ''){
if(!$redirectUrl) $redirectUrl = site_url();
$return = str_replace("&", '&', wp_logout_url($redirectUrl));
return $return;

* Bypass logout confirmation on nonce verification failure
function logout_without_confirmation($action, $result){
if(!$result && ($action == 'log-out')){
add_action( 'check_admin_referer', 'logout_without_confirmation', 1, 2);

I tried it out and it works.

First, if WP can't find a valid wpnounce parameter & value in the logout URL, it will display the logout confirmation page. The above code adds the necessary wpnounce parameter & value on the fly.

The next part is adding the logout URL in the menu item or wherever. The logout URL should be:


That's it.

This code can be added in theme's function.php file or in a plugin like Code Snippets.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.