By default, WooCommerce will redirect customers to the My Account page after logging out. However, you may want them to go somewhere else – here’s how.
Firstly, you’ll need to make sure that you are overriding the default WooCommerce template files in your theme. If you’ve already got a woocommerce folder in your theme’s directory, you’ll be okay to continue onwards. If you don’t see one, please first take a look at the Template Structure Documentation and ensure that the correct template files are copied to your theme.
Now let’s open up the file found in /wp-content/YOUR_THEME/woocommerce/myaccount/my-account.php.
Approximately around line 21, you will find the following line:
wp_logout_url( get_permalink( wc_get_page_id( 'myaccount' ) ) )
We’re going to want to change this line to set a custom URL to redirect to after logging out. If, for example, you wanted to send customers to Google after logging out, you could change it to this:
wp_logout_url( 'http://google.com/' )
You can even use functions like the core WordPress home_url function to redirect customers to the home page, like so:
wp_logout_url( home_url() )
If you’d like, you can read more about the wp_logout_url function in the WordPress Codex.
Latest posts by Chris Mok (see all)
- WHM – Change account setup date manually - August 25, 2016
- Manually generate the notifications to who over disk quota - August 23, 2016
- Help Desk Management: What is Level 1, Level 2, and Level 3 Help Desk support? - July 27, 2016
- Find and delete files greater than a given size from the Linux command line - April 18, 2016
- How to change WordPress default email’s From name and address - April 15, 2016