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

I have a couple issues with the way Wordpress handles redirects on login and logout.

Standard behaviour is:

login: /wp-login.php (with no redirect_to url) -> /wp-admin.php 
logout: /wp-admin.php -> /wp-login.php

What want is:

login: /wp-login.php (with no redirect_to url) -> homepage
logout: /wp-admin.php -> homepage

Would prefer a coded solution please. It helps me to learn and understand how Wordpress works.

Thank you

share|improve this question
up vote 3 down vote accepted

This really does belong in a plugin, but you can just as easily drop it in your theme's functions.php

function default_login_redirect( $redirect, $request_redirect )
    if ( $request_redirect === '' )
        $redirect = home_url();
    return $redirect; 
add_filter( 'login_redirect', 'default_login_redirect', 10, 2 );
share|improve this answer
No worries. It's going into a custom plugin. Thanks. – EddyR Jan 13 '12 at 13:36
That worked. Those filters are hard to find sometimes :) – EddyR Jan 13 '12 at 13:47

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.