This snippet is good for e-commerce stores or anywhere that customers can be logged in, it ensures they don’t see the default WordPress login page, but are instead taken to the home page.
<?php
/**
* Snippet Name: Redirect to homepage after logout
* Snippet URL: https://www.wpcustoms.net/snippets/redirect-homepage-logout/
*/
function wpc_auto_redirect_after_logout(){
wp_redirect( home_url() );
exit();
}
add_action('wp_logout','wpc_auto_redirect_after_logout');