Whenever a customer logs out from WooCommerce, they are redirected to the My Account page URL.
But when you use separate Login and Registration pages, or whenever you have custom landing pages you wish your customers to see instead of the default My Account page, we can set a custom URL by code and safely redirect the just-logged-out customer there. Here’s the quick fix – enjoy!
PHP Snippet: Redirect Logged Out Customers to Custom URL @ My Account
/**
* @snippet Custom Redirect for Logouts @ WooCommerce My Account
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 7
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_logout_default_redirect_url', 'bbloomer_redirect_after_woocommerce_logout' );
function bbloomer_redirect_after_woocommerce_logout() {
return 'https://example.com/see-you-soon';
}
This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
Related content
WooCommerce: Custom Add to Cart URLs – The Ultimate Guide In WooCommerce you can add a product to the cart via a custom link. You just need to use the “add-to-cart” URL parameter followed by the product ID. This tutorial will show you how to create custom URLs to add simple, variable and grouped products to the cart – as well as defining the add […]
WooCommerce: Separate Login, Registration, My Account Pages There are times when you need to send logged out customers to a Login page and unregistered customers to a standalone Register page. As you know, the WooCommerce My Account page, which contains the Login Username or email address *Required Password *Required Remember me Log in Lost your password? shortcode, has both Login and Registration forms when […]
WooCommerce: Add New Tab @ My Account Page One of the features of Business Bloomer Club is the provision of Premium WooCommerce Q&A Support to supporters who enroll. So, how to add an extra “tab” to the My Account page, and how to add content inside it? Here’s the code I used (thanks to Mike Jolley for inspiration) – feel free to leave […]
WooCommerce: How To Make A Website GDPR Compliant? (12 Steps) Ok, we all know that the EU General Data Protection Regulation (GDPR) will come into force on the 25th May 2018. So the main question is: what changes do we need to make on our WooCommerce website to become compliant? And another important query might be: how does GDPR affect non-European WooCommerce websites? In this […]
WooCommerce Visual Hook Guide: My Account Pages Hey WooCustomizers, the Visual Hook Guide is back ๐ In this episode, I’ve created a visual HTML hook guide for the WooCommerce Account Pages (there are multiple pages such as the My Account as logged in user, My Account as logged out, etc). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve […]
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli
6 thoughts on “WooCommerce: Custom Logout Redirect @ My Account”
danielle
In my case I had to use
add_filter( 'template_redirect', 'log_out_customer' );
function log_out_customer() {
global $wp;
if ( isset( $wp->query_vars['customer-logout'] ) ) {
wp_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'home' ) ) ) );
exit;
}
}
to redirect to home on logout. Other URLs can be chosen using the permalink and wc_get_page_permalink call.
Hi there!
Your code-snippet is very good and works right away! Thanks, I became a fan. ๐
Do you have a similar snippet or solution for a “redirect after password reset” ? I have a good looking and working login-form and I want to leave the WooCommerce-Login out of sight as much as possible.
I would become a supporter right away if you have such a redirect in your large collection! I did not find it on your page, but maybe … how knows?
I am a complete newbie to WooCommerce and feel blessed to have found your site.
Thank you very much for your work you already did and for your answer in advance.
(I hope this is the right place to write !?)
Kind regards, Christian
Hello Christian, thanks for your lovely message and for having joined the Business Bloomer Club!
In case of a successful password reset, the “woocommerce_customer_reset_password” hook triggers, and you can use it to redirect users to wherever you like.
I am using your custom login/register/redirect snippets, however the redirect to the homepage after logout does not seem to work. it takes me back to the default woocommerce login/register screen.
So, it redirects you to the My Account page it seems… Not fully sure. This happens when you click on the “LOGOUT” tab of the My Account page? Or where are you trying to log out from?
Questions? Feedback? Customization? Leave your comment now! _____
If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!
In my case I had to use
to redirect to home on logout. Other URLs can be chosen using the permalink and wc_get_page_permalink call.
Thank you!
Hi there!
Your code-snippet is very good and works right away! Thanks, I became a fan. ๐
Do you have a similar snippet or solution for a “redirect after password reset” ? I have a good looking and working login-form and I want to leave the WooCommerce-Login out of sight as much as possible.
I would become a supporter right away if you have such a redirect in your large collection! I did not find it on your page, but maybe … how knows?
I am a complete newbie to WooCommerce and feel blessed to have found your site.
Thank you very much for your work you already did and for your answer in advance.
(I hope this is the right place to write !?)
Kind regards, Christian
Hello Christian, thanks for your lovely message and for having joined the Business Bloomer Club!
In case of a successful password reset, the “woocommerce_customer_reset_password” hook triggers, and you can use it to redirect users to wherever you like.
Something like this should work:
Let me know
I am using your custom login/register/redirect snippets, however the redirect to the homepage after logout does not seem to work. it takes me back to the default woocommerce login/register screen.
So, it redirects you to the My Account page it seems… Not fully sure. This happens when you click on the “LOGOUT” tab of the My Account page? Or where are you trying to log out from?