How to Remove Dashboard from WooCommerce My Account Menu
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.

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;
}
}
- It is not enough to use
is_account_page()
, because it returns true on every account page, so it is easy to end up with an endless redirect. But the thing is, that the Dashboard page is the only page among the account pages which doesn’t have an endpoint, so the second condition helps us with it. - I use
wc_get_account_endpoint_url()
to get the URL of the Orders page because I think it is the most correct method. This function was described in this tutorial. You can also find other account page endpoints there.
Related

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
thank you for your code, it is so optimized comparing to others