It’s possible to redirect your users to a page other than My Account when they login or register. Try adding the following code using the Code Snippets plugin, or via your preferred method.
Redirect at Login
To redirect at login, you need to use the woocommerce_login_redirect
filter.
/** * Redirect to shop after login. * * @param $redirect * @param $user * * @return false|string */ function iconic_login_redirect( $redirect, $user ) { $redirect_page_id = url_to_postid( $redirect ); $checkout_page_id = wc_get_page_id( 'checkout' ); if( $redirect_page_id == $checkout_page_id ) { return $redirect; } return wc_get_page_permalink( 'shop' ); } add_filter( 'woocommerce_login_redirect', 'iconic_login_redirect' );
First of all, we’re checking whether the attempted redirect is for the checkout page; this catches users who are logging in at checkout, as it’s likely they will want to go back there and not some other page on the site. If they’re not at checkout, we redirect them to the WooCommerce shop page. You could even use the $user
variable to redirect users based on their capabilities.
Redirect after Registration
To redirect after registration, you need to use the woocommerce_registration_redirect
filter.
/** * Redirect after registration. * * @param $redirect * * @return string */ function iconic_register_redirect( $redirect ) { return wc_get_page_permalink( 'shop' ); } add_filter( 'woocommerce_registration_redirect', 'iconic_register_redirect' );