WooCommerce - My Account - logout and redirect to Homepage
10,360
add_action('wp_logout','auto_redirect_after_logout');
function auto_redirect_after_logout(){
wp_redirect( home_url() );
exit();
}
Author by
Rich72
Updated on June 05, 2022Comments
-
Rich72 almost 2 years
Once a user is in their My Account page on WooCommerce I'd like them to hit logout and be redirected to my Homepage rather than end up on the login page.
-
Rich72 about 5 yearsI've added this into my function.php file. When I clicked to access My Account the login page did not fire. Nothing fired in fact. Is it not as simple as adding this code into the function.php file?
-
Rich72 about 5 yearsI added the code into my child theme. apexgray.co.uk/my-account
-
Rich72 about 5 yearsI'll add the code back into the function.php file again and let you know...
-
Rich72 about 5 yearsMaybe my question wasn't clear. When the user has logged into their account and they've finished, when they hit logout I ideally would like them to go to the home page.
-
Rich72 about 5 yearsI think my original question was confusing...!
-
Rich72 about 5 yearsworks a charm Mujeeba! Thank you. Wish I knew how to do this!