WordPress logout redirect (3.0 beta1)

For those that use WordPress for their blog, you will be aware that when you logout you get directed to the login page (default action) However I find this a little annoying as I’d prefer to be placed back to the blog front page. I had a look through the available plug-ins to see if there was one that would take care of this for me, but there are none that specifically target logout, rather to set a redirect upon login!

If you take a look at the wp-login.php file and search for the following … (line 354)

Before…

case ‘logout’ :
check_admin_referer(‘log-out’);
wp_logout();

$redirect_to = !empty( $_REQUEST[‘redirect_to’] ) ? $_REQUEST[‘redirect_to’] : ‘wp-login.php?loggedout=true’;
wp_safe_redirect( $redirect_to );
exit();

After…

case ‘logout’ :
check_admin_referer(‘log-out’);
wp_logout();

$redirect_to = !empty( $_REQUEST[‘redirect_to’] ) ? $_REQUEST[‘redirect_to’] : ‘index.php?loggedout=true’;
wp_safe_redirect( $redirect_to );
exit();

You notice the reference to wp-login.php I have simply changed this to index.php and now when I logout from my blog I am redirected to the main page of my blog!  😀

© 2010, Scott Evans. Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

2 Replies to “WordPress logout redirect (3.0 beta1)”

Comments are closed.