WooCommerce Logout Redirect

WooCommerce custom page showing after logout

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

This guide shows you how you can redirect users to any page on your site when they logout instead of the default My Account login page. Simply enter the Post ID of the URL you wish to redirect users to when they logout. To get the post ID, simply edit that page and the URL will show you the integer ID. Alternatively, you can hover over the post in the backend editor where you “Quick Edit” posts and you’ll see the ID there too.

				
					/**
 * Snippet Name: WooCommerce Logout Redirect
 * Snippet Author: ecommercehints.com
 */

add_action('wp_logout', 'ecommercehints_logout_redirect');
function ecommercehints_logout_redirect(){
    wp_safe_redirect( get_permalink( 121 ) );	// The Post ID to redirect users to when they logout
    exit;
}
				
			

Snippet Benefits

  • Redirect your users to a custom page when they logout of their account
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers