I wanted to remove the home/dashboard menu item in the Woocommerce my account dashboard and found a great snippet to redirect the visitors from the dashboard to another page upon arrival. This way both the menu item is gone and the page is inaccessible.
I found the snippet on Misha Rudrastyh‘s website, in the following article:
But after the change, my custom pages stopped working.
Apparently, my custom pages were not registered in Woocommerce’s query vars so the
WC()->query->get_current_endpoint() function would return empty thinking the visitor requested the dashboard/home page.
The right way of setting up menu items and custom pages in Woocommerce my account
Woocommerce allows us to alter the menu items and pages with a couple of neat hooks like:
The GIST below shows how we can use these hooks together with Misha’s snippet.