How To Disable Admin Menu Items By Configuration Value in Magento 2

How To Disable Admin Menu Items By Configuration Value in Magento 2

The Magento 2 admin interface must be kept simple. Any unnecessary menu should be removed in order to keep the admin panel as clean as possible. Also, if you manage multiple admin users, you may want to hide some menu items from some of the users.

In case of the Magento 2 extensions, if it’s disabled from the configuration section, it’s useless to show menu items in the admin panel which occupies the space and make the menu lengthy. It’s where you need to disable admin menu items by configuration value in Magento 2.

However, it may not be feasible all the time to entirely remove a menu or tab altogether. You may need it when the requirements differ.

The below screenshots show how the admin menu tab is enabled and then disabled based on the configuration value:

Configuration Enabled: 

Configuration Enabled

The solution will fetch the configuration value, if it’s disabled, it will hide the menu items:

Configuration Disabled

Method To Disable Admin Menu Items By Configuration Value in Magento 2:

Add the below code snippet in menu.xml  file:

Here, the value of “section_id/groupe_id/field_id” is based on the system configuration value.

That’s it.

An easy way to keep the backend admin panel sorted!

I’d be happy to solve any doubts on the topic that you may mention in the Comments section below.

I’d be very grateful if you helped share this helpful post on social media to fellow developers!

Thanks!

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 12 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

2 comments On How To Disable Admin Menu Items By Configuration Value in Magento 2

Leave a reply:

Your email address will not be published.