How Gatemi My Account Works

Three rules govern both editions.

The three rules

The configuration is a patch, never a replacement. WooCommerce builds the account menu as a list and passes it through the woocommerce_account_menu_items filter, where other plugins add their tabs. This plugin changes that list at priority 20 — renaming, reordering, removing — and leaves everything it has no instruction for exactly as it arrived. A plugin that returned its own list of the seven tabs it knows about would delete every other plugin's tab the day it was activated. It also makes hiding reversible: untick Hide and the tab comes back exactly as WooCommerce or the other plugin defined it.

An address WooCommerce already uses is refused, and you are told. Registering orders as your own tab would not fail loudly; it would win, and a customer's real order history would become whatever you typed. So those addresses are refused when you save, and the screen names them.

Rewrite rules are flushed only when the list of tabs changes. A new tab's address only works once WordPress' rewrite rules know it, so the plugin flushes them — but flushing on every page load is one of the most expensive things a plugin can do. It keeps a fingerprint of the tab addresses and flushes on the one request where it has changed.

Step by step

1. Building the menu

When a customer opens My Account:

  1. WooCommerce and every other plugin build the menu as usual.
  2. This plugin adds your own tabs to the end of it (a tab already in the list is left alone).
  3. Each tab is checked against its row in The menu:
    • Hide ticked → the tab is removed from the list.
    • Full edition: Only these roles set → the tab stays only for a user holding at least one of those roles. A user can hold several roles, and every one is read.
    • Free edition: a row the full edition limited to roles is removed for everybody. The free edition does not evaluate roles, and the strict reading means a tab you meant for trade customers is never shown to the public.
  4. Label replaces the name, when it is filled in.
  5. The tabs are sorted: numbered ones first by number, then the rest in the order they arrived. The sort is stable, so moving one tab does not shuffle the others.

2. Icons — Full edition

An icon is either a Dashicons class or a short piece of text:

  • A Dashicons class (dashicons-cart) is added to the menu item's CSS classes through WooCommerce's own woocommerce_account_menu_item_classes filter, and Dashicons is loaded on account pages only when some tab uses one.
  • Text — usually an emoji — is put in front of the label, where WooCommerce escapes it like any label.

The plugin never rewrites the menu's HTML, because a theme that renders its own menu template would break.

3. Your own tabs

Each tab is a real WooCommerce account endpoint:

  1. Its address is registered as a rewrite endpoint on init, the same way WooCommerce registers Orders and Addresses.
  2. Its content is printed on woocommerce_account_{address}_endpoint, the hook WooCommerce uses for its own tabs, so your tab uses your theme's account template, styling and menu.
  3. The content is filtered to the HTML allowed in posts, and shortcodes run. Full edition: a tab with a page chosen shows that page's content through WordPress' content filters, so blocks render as they do on the page itself.

Free edition: only the first tab is served, and only when it uses written text and has no role limit. A tab the full edition set to show a page, or limited to roles, is kept in storage but not served.

4. The dashboard note — Full edition

When a note is set, it is printed at the top of the dashboard (woocommerce_account_dashboard, priority 5), above WooCommerce's own text, inside <div class="gmma-dashboard-top">.

Worked example

A shop with WooCommerce Subscriptions active, using the full edition:

Tab Label Order Hide Roles
dashboard Overview 1
orders 2
subscriptions My plans 3
downloads ✓
trade-prices (own tab) Trade prices 4 wholesale_customer

A retail customer sees Overview, Orders, My plans, Addresses, Payment methods, Account details, Log out. A wholesale customer also sees Trade prices fourth. Subscriptions' own tab is renamed, not rebuilt — its links and its page are still Subscriptions'.

What it does not do

  • It does not change the pages behind WooCommerce's own tabs, only their place and name in the menu.
  • Hiding a tab removes its link, not its page. Its address still works for anyone who knows it.
  • It writes nothing to users, orders or products.
Shopping Cart
Scroll to Top