In order to remove a menu item from the customers area, say the Api Keys menu item, we can create a very simple extension to hook into the menu while it is generated and simply remove the given item.
This extension is based on the example extension that should be used each time when you develop mailwizz extensions.
We will name this extension “remove-api-key-item-from-menu” just so that it will be clear what it does and we will install it in the end as described in the extension install guide.
Now, the customers area menu is generated by the class
and if we look inside it for hooks, we can see that somewhere at line 163 it defines following code:
$menuItems = (array)Yii::app()->hooks->applyFilters('customer_left_navigation_menu_items', $menuItems);
This means we can hook into the “customer_left_navigation_menu_items” filter and get access to the $menuItems variable and unset what items we need to.
If the extension folder name is “remove-api-key-item-from-menu” it means our extension entry class file has to be named “RemoveApiKeyItemFromMenuExt.php” and it has to be placed in the “remove-api-key-item-from-menu” folder having the following contents:
The main part is the run() method, where we hook into the main menu and we unset the menu item we want to.
The extension is also attached so you can play with it to remove other menu items as well, or to even add new ones.