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
1 Answer
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 );