My Account

WooCommerce Login Redirect

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution. You will need the Post ID if you are using the custom redirect option.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

By default, when a user logs into their account on your WooCommerce website, they are redirected to their dashboard on the My Account page. This guide shows you how to change this and redirect the user to any page you like. We’ve also included a handful of most popular pages including how to redirect the user to: Home Page, Shop Page, Cart Page, Checkout Page, and any custom post or page, upon login. Simply comment-out/un-comment the appropriate redirect you would like in place. For the custom page redirect, you will need the post ID of said page. To get the post ID, simply edit that page and the URL will show you the integer ID. Alternatively, you can hover over the post in the back-end editor where you “Quick Edit” posts and you’ll see the ID there too. This particular example redirects the user to a custom page upon WooCommerce account login.

/**
 * Snippet Name:	WooCommerce Login Redirect
 * Snippet Author:	ecommercehints.com
 */

add_filter( 'woocommerce_login_redirect', 'ecommercehints_login_redirect', 10, 1 );
function ecommercehints_login_redirect( $redirection_url ){
    // $redirection_url = get_home_url();								// Home page
	// $redirection_url = get_permalink( wc_get_page_id( 'shop' ) );	// Shop Page
	// $redirection_url = wc_get_cart_url();							// Cart Page
	// $redirection_url = wc_get_checkout_url();						// Checkout Page
	$redirection_url = get_permalink( 121 ); 							// Custom Page (The ID of the post/page you would like to redirect to - replace '121')
    return $redirection_url;
}

Snippet Benefits

  • Redirect the user to a custom page upon WooCommerce account login.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 10% off on your first month with us.

26027
WELCOME OFFER