WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Right now when I log out via:

<a href="<?php bloginfo('url'); ?>/wp-login.php?action=logout">Log out</a>

it redirects me to the page where I need to confirm the log out.

How to eliminate the confirmation and redirect to the homepage after logout?

share|improve this question
up vote 10 down vote accepted

This happens because you are missing the neccessary nonce in the URL, which is being checked in wp-login.php

case 'logout' :

Use wp_logout_url in order to retreive the URL including the nonce. If you want to redirect to a custom URL, simply pass it as an argument.

<a href="<?php echo wp_logout_url('/redirect/url/goes/here') ?>">Log out</a>

You could also use wp_loginout which generates the link for you including translation:

echo wp_loginout('/redirect/url/goes/here')
share|improve this answer
echo wp_loginout('/redirect/url/goes/here') is working fine.. – mAyUr DeVmUrArI Oct 30 '15 at 5:32

If you can't use wp_logout_url() funcition, You can turn off this validation using this code:

add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
     * Allow logout without confirmation
    if ($action == "log-out" && !isset($_GET['_wpnonce'])) {
        $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '';
        $location = str_replace('&amp;', '&', wp_logout_url($redirect_to));;
        header("Location: $location");

Add it in your functions.php

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.