Send Customers to the Shop After Login
Takes customers to the shop page after they log in or register through WooCommerce, instead of the My Account dashboard.
Opens WPIDE on
Code
$wpide_customer_redirect = function ( $redirect, $user = null ) {
$user = $user instanceof WP_User ? $user : wp_get_current_user();
if ( ! $user || user_can( $user, 'edit_posts' ) || user_can( $user, 'manage_woocommerce' ) ) {
return $redirect;
}
$shop = wc_get_page_permalink( 'shop' );
return $shop ? $shop : $redirect;
};
add_filter( 'woocommerce_login_redirect', $wpide_customer_redirect, 20, 2 );
add_filter( 'woocommerce_registration_redirect', $wpide_customer_redirect, 20 );
Notes
Shop managers and administrators keep the default destination.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.