By default, WooCommerce redirects all users to the MyListing Dashboard (i.e., My Account), which may not be desirable for website owners.
Customization Notes
By default, this code snippet redirects all users with the customer role to your Home page. Please see the video for instructions on how to adjust this code snippet.
- Line 5 (Default Setting): Redirects users with the ‘customer’ role.
- Line 6 (Default Setting): Redirects to your Home page.
- Line 7: Redirect to your Shop page.
- Line 8: Redirect to a custom URL on your website.
- Line 9: Redirect to a custom URL on a different website.
- Line 10: Redirect to a custom tab within your website’s ‘My Account’ area.
add_filter( 'woocommerce_login_redirect', 'wptu_customer_login_redirect', 9999, 2 );
function wptu_customer_login_redirect( $redirect, $user ) {
if ( wc_user_has_role( $user, 'customer' ) ) {
$redirect = get_home_url(); // Home Page
//$redirect = wc_get_page_permalink( 'shop' ); // Shop Page
//$redirect = '/custom_url'; // Custom URL - Same Site
//$redirect = 'https://custom.url'; // Custom URL - Different Site
//$redirect = add_query_arg( 'password-reset', 'true', wc_get_page_permalink( 'myaccount' ) ); // Custom 'My Account' Tab
}
return $redirect;
}