WordPress: Redirect user after login or logout

I found it annoying when WordPress took the user to the login page after logging out.

It would be more intuitive if they were taken back to the homepage.

To do that, search for wp_loginout() in your template file and change the first parameter given to the page you want to redirect to.

To redirect back to "http://yoursite.com/index.php", use:

<li><?php wp_loginout('/index.php'); ?></li>

Or "http://yoursite.com/page/1":


This one takes you back to the root path of the site, "http://yoursite.com":


If you only want to modify logout and not login, then use wp_logout_url(). Conversely you can use wp_login_url() for just the login URL.


If you want to do this using a plugin, you can use the "login_redirect" filter.

add_filter('login_redirect', 'plugin_admin_redirect');
function plugin_admin_redirect($redirect_to, $url_redirect_to = '', $user = null) {
    return '/';

This will redirect you to the homepage after you login.

*edit 21/07/2010*

  • Added plugin/filter method
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog