Title: Redirection after logout
Last modified: August 19, 2016

---

# Redirection after logout

 *  Resolved [schso](https://wordpress.org/support/users/schso/)
 * (@schso)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/redirection-after-logout/)
 * Hello,
    I’d like the logout page/action to be followed by the display of the 
   home page, instead of the login/logout WP page. I have 2 pages to modify, one
   includes the todo mini forms plugins.
 * This is the code, does anyone know how to redirect to another page ?
    Thanks 
   in advance
 * Schso ([http://peepchatou.free.fr](http://peepchatou.free.fr), and go to Forum)
 * </p>
 * And for the tdomf form :
 * <p>Vous êtes <b>%%USERNAME%%</b>. <?php wp_loginout(); ?></p>

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [chaoskaizer](https://wordpress.org/support/users/chaoskaizer/)
 * (@chaoskaizer)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908238)
 * try
 *     ```
       <?php
       $redirect = '&amp;redirect_to='.urlencode(wp_make_link_relative(get_option('siteurl')));
       $uri = wp_nonce_url( site_url("wp-login.php?action=logout$redirect", 'login'), 'log-out' );
       ?>
       <a href="<?php echo $uri;?>"><?php _e('logout');?></a>
       ```
   
 *  Thread Starter [schso](https://wordpress.org/support/users/schso/)
 * (@schso)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908277)
 * That’s great, thanks a lot.
    New request now this one is solved : I am in a post(
   no longer in the home page), how may I redirect where I am instead of the home
   page ?
 * Thanks again, it’s much better now !
 * Schso
 *  Thread Starter [schso](https://wordpress.org/support/users/schso/)
 * (@schso)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908285)
 * Ice on the cake, I have the same redirection to do when I login from a post page.
 * <p>Veuillez préciser votre nom et votre adresse mail. Vous pouvez [vous connecter](http://peepchatou.free.fr/blog2/wp-login.php?redirect_to=/blog2/#tdomf_form1)
   si vous êtes un membre du bureau de l’association.</p>
 * I’d like to stay in the post page instead of going to the home page of the blog.
 * It would be nicer this way, but it’s already gread.
    Thanks,
 * Schso
 *  Thread Starter [schso](https://wordpress.org/support/users/schso/)
 * (@schso)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908286)
 * oups sorry
 * `<p>Veuillez préciser votre nom et votre adresse mail. Vous pouvez`[vous connecter](http://peepchatou.free.fr/blog2/wp-login.php?redirect_to=/blog2/#tdomf_form1)
   si vous êtes un membre du bureau de l’association.</p>`
 *  [chaoskaizer](https://wordpress.org/support/users/chaoskaizer/)
 * (@chaoskaizer)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908289)
 * use the following function to get the current url
 *     ```
       <?php
       function self_uri()
       {
   
           $url = 'http';
           $script_name = '';
   
           if (isset($_SERVER['REQUEST_URI'])):
               $script_name = $_SERVER['REQUEST_URI'];
   
           else:
               $script_name = $_SERVER['PHP_SELF'];
   
               if ($_SERVER['QUERY_STRING'] > ' '):
                   $script_name .= '?' . $_SERVER['QUERY_STRING'];
   
               endif;
           endif;
   
               if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
                   $url .= 's';
   
               $url .= '://';
   
               if ($_SERVER['SERVER_PORT'] != '80'):
                   $url .= $_SERVER['HTTP_HOST'] . ':' . $_SERVER['SERVER_PORT'] . $script_name;
   
               else:
                   $url .= $_SERVER['HTTP_HOST'] . $script_name;
   
               endif;
   
           return $url;
       }
       //
       // $redirect = '&amp;redirect_to='.urlencode(self_uri());
       //
       ?>
       ```
   
 *  Thread Starter [schso](https://wordpress.org/support/users/schso/)
 * (@schso)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908298)
 * Wow, everything’s just fine.
    You have been very helpful, thanks a lot.
 * Schso
 *  [charlieperrins](https://wordpress.org/support/users/charlieperrins/)
 * (@charlieperrins)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908463)
 * That’s a great tip, thanks very much. Works perfectly in wp 2.7.1
 *  [jeffery2k9](https://wordpress.org/support/users/jeffery2k9/)
 * (@jeffery2k9)
 * [17 years ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908467)
 * good , i will give it a try…..thanx
 *  [whatshakin](https://wordpress.org/support/users/whatshakin/)
 * (@whatshakin)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908505)
 * which files and where do these lines of code go chaoskaizer?
 * I missed something 🙂

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Redirection after logout’ is closed to new replies.

## Tags

 * [Logout](https://wordpress.org/support/topic-tag/logout/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)
 * [wp_nonce_url](https://wordpress.org/support/topic-tag/wp_nonce_url/)

 * 9 replies
 * 5 participants
 * Last reply from: [whatshakin](https://wordpress.org/support/users/whatshakin/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/redirection-after-logout/#post-908505)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
