Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WP: Redirect to home page for WooCommerce login and logout. #ST3
// redirects for login / logout
add_filter('woocommerce_login_redirect', 'login_redirect');
function login_redirect($redirect_to) {
return home_url();
function logout_redirect(){
wp_redirect( home_url() );

This comment has been minimized.

Copy link

rbaccaro commented Mar 16, 2016

Hi gbot,

Is it possible to keep the users in the same or previous page while logging in, especially when they are buying, using the checkout and cart? It seems that is_checkout does not work there. I tried everything I know so far.

Could you please assist me?

Thank you,


This comment has been minimized.

Copy link
Owner Author

gbot commented Sep 24, 2016


Sorry, pretty slack on the reply...

This should help you, though you've probably figured it out by now.


This comment has been minimized.

Copy link

AppleTechy commented Dec 19, 2017

Alright so I was pointed to your php file. Can I just add this to the theme's function.php file? Rather than the WooCommerce plugin folder?


This comment has been minimized.

Copy link

Nikoogle commented Feb 14, 2019

Quick and easy.
Thank you.


This comment has been minimized.

Copy link

corypina commented Apr 10, 2019

Thank you from 2019! I was having a tough time getting the logout redirect to work on a WooCommerce site. I'm assuming WooCommerce makes the logout redirect misbehave, but whatever it is, it solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.