How to Remove Dashboard from WooCommerce My Account Menu

In this tutorial I will show not only how to remove a menu link (it is easy-breezy), but also how to redirect correcly to another my account subpage.

Long time ago I published a tutorial about my account menu in WooCommerce. The most asked question in comments was about removing “Dashboard” from the menu.

It was not that simple to cover this topic in comments. But if you follow the steps below, everything will be just OK.

Remove Dashboard from WooCommerce my account menu

Step 1. Remove “Dashboard” from My Account Menu

Let’s begin with something simple. By the way I’ve already covered this topic deeply here. To remove Dashboard from the account menu all you have to do is to use this code in your functions.php file. And remember that all the code from this tutorial should go to your functions.php (of course better if it is your custom theme or a child theme).

add_filter( 'woocommerce_account_menu_items', 'misha_remove_my_account_dashboard' );
function misha_remove_my_account_dashboard( $menu_links ){
 
	unset( $menu_links['dashboard'] );
	return $menu_links;
 
}

It’s a piece of cake 😁🍰 I can not say the same about the second part!

Step 2. How to Detect the Dashboard Page and Redirect to the Orders

… or to any other WooCommerce Account subpage.

And as you probably noticed, it is not enough to just remove the Dashboard menu link from the my account menu. Because when a customer signs in to the website, he/she is going to be landed on… yes, Dashboard page!

And of course, wp_get_page_permalink( 'myaccount' ) is probably used in your theme files, which also sends users to the Dashboard page!

So I think it is not enough just to redirect users after login and we should redirect customers every time they are trying to access the Dashboard.

Enough words, here is the working code:

add_action('template_redirect', 'misha_redirect_to_orders_from_dashboard' );
 
function misha_redirect_to_orders_from_dashboard(){
 
	if( is_account_page() && empty( WC()->query->get_current_endpoint() ) ){
		wp_safe_redirect( wc_get_account_endpoint_url( 'orders' ) );
		exit;
	}
 
}

Related

Misha Rudrastyh

Misha Rudrastyh

I love WordPress, WooCommerce and Gutenberg so much. 10 yrs of experience.

Need some custom developer help? Let me know

Follow Misha

Need some help with WooCommerce?

If you need some professional developer help, I will be happy to assist you.

Contact me Who I am?

Leave a comment

php js HTML CSS Code

I will only use your personal information to contact you. Privacy Policy