Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.