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 businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @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';
}
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?