Marinus Klasen

Marinus Klasen

  • Development
  • Consultancy
  • Developer Resources
  • Blog
  • Contact

August 16, 2022

Managing menu items and custom pages in Woocommerce My account

Marinus Klasen

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:

https://rudrastyh.com/woocommerce/remove-dashboard-from-my-account-menu.html

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:

  • woocommerce_account_menu_items
  • woocommerce_account_***_endpoint
  • woocommerce_get_query_vars.

The GIST below shows how we can use these hooks together with Misha’s snippet.

About Marinus Klasen

Marinus has been working in software/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge.

Marinus Klasen on Twitter

Looking for a WordPress expert?
Hire top notch developers on Codeable!

Consult an expert

Comments

  1. Piotr Madej says

    August 21, 2023 at 7:26 pm

    Bingo, couldn’t have figured it myself for almost 2 hours, then found this post. Thank you!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get in touch

Contact me using the details below

Marinus Klasen

Wilhelmina van Pruisenweg 35, 2595 AN Den Haag

marinus@mklasen.com
twitter.com/marinusklasen
linkedin.com/in/marinusklasen

  • GitHub
  • LinkedIn
  • Twitter

Have you read?

  • Elementor Widget UsageMarch 27, 2025
  • Programmatically showing popups with ElementorMarch 25, 2025
  • The Elementor sanitize_settings errorSeptember 12, 2024
  • Announcing.. Wooping Shop Health!June 13, 2024
  • Swiper setup when using wp-scriptsMarch 14, 2024

Copyright © 2025 ยท Marinus Klasen | Webdesign by Team Rood