Redirect Users to the Page They Logged In From
-
we see that after users log in to our website, they are redirected to the ‘My Account’ page. Instead, we want them to be returned to the page they were on before logging in, such as the homepage, shop page, or any other page from which they initiated the login process.
Hi bhunes.crafts,
Thanks for reaching to us.
Please add this code to the functions.php of the child theme:
function custom_shop_page_redirect() {
if( is_shop() ){
wp_redirect( home_url('/') );
exit();
}
}
add_action( 'template_redirect', 'custom_shop_page_redirect' );
Regards,
This code is redirecting to the home page. Instead, it should redirect the user to the page from which they initiated the login process. For example, if the user was on a specific page in the shop or the cart page, they should be redirected back to that same page after logging in.
Hi bhunes.crafts,
Unfortunately, there is no such option by default. You need to find a third-party plugin to achieve more functionality that best suits you.
Best Regards,