{"id":11880,"date":"2020-10-21T14:49:06","date_gmt":"2020-10-21T09:19:06","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=11880"},"modified":"2020-10-27T11:08:03","modified_gmt":"2020-10-27T05:38:03","slug":"magento-2-hide-admin-menu-based-system-configuration","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/magento\/magento-2-hide-admin-menu-based-system-configuration\/","title":{"rendered":"Magento 2 &#8211; How to Hide Admin Menu Based on System Configuration"},"content":{"rendered":"<p>In this post I am going to explain how to hide admin menu based on system config in Magento 2.<\/p>\n<p>In order to add admin menu we write code in menu.xml file, which is located at <strong>&lt;vendor&gt;\/&lt;module&gt;\/etc\/adminhtml\/<\/strong>.<\/p>\n<p>So now let\u2019s see how you can hide menu based on conditions. Check the below code snippet.<\/p>\n<pre class=\"lang:default decode:true \">&lt;?xml version=\"1.0\"?&gt;\r\n\r\n&lt;config xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"urn:magento:module:Magento_Backend:etc\/menu.xsd\"&gt;\r\n    &lt;menu&gt;\r\n        &lt;add id=\"Ht_Mymodule::title\" title=\"Title\" module=\"Ht_Mymodule\" sortOrder=\"10\" resource=\"Ht_Mymodule::title\"\/&gt;\r\n        &lt;add id=\"Ht_Mymodule::menu\" title=\"Menu\" module=\"Ht_Mymodule\" sortOrder=\"10\" parent=\"Ht_Mymodule::title\" dependsOnModule=\"Ht_Mymodule\" resource=\"Ht_Mymodule::menu\"\/&gt;\r\n        &lt;add id=\"Ht_Mymodule::submenu\" title=\"Sub Menu\" module=\"Ht_Mymodule\" sortOrder=\"1\" parent=\"Ht_Mymodule::menu\" action=\"routename\" resource=\"Ht_Mymodule::submenu\" dependsOnConfig=\"mymodulesection\/general\/enabled\"\/&gt;\r\n    &lt;\/menu&gt;\r\n&lt;\/config&gt;<\/pre>\n<p>We have used below attributes in above code snippet.<\/p>\n<p><strong>dependsOnModule:<\/strong> Used to manage visibility of the menu based on availability on any module.<br \/>\n<strong>dependsOnConfig:<\/strong> Used to manage visibility of the menu based on system config field.<\/p>\n<div class=\"angwp_12010 _ning_cont _ning_hidden _ning_outer _align_center responsive\" data-size=\"custom\" data-bid=\"12010\" data-aid=\"0\" style=\"max-width:800px; width:100%;height:inherit;\"><div class=\"_ning_label _left\" style=\"\"><\/div><div class=\"_ning_inner\" style=\"\"><a href=\"https:\/\/www.hiddentechies.com\/blog?_dnlink=12010&t=1775808706\" class=\"strack_cli _ning_link\" target=\"_blank\">&nbsp;<\/a><div class=\"_ning_elmt\"><img decoding=\"async\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/angwp\/items\/12010\/Banner-2.png\" \/><\/div><\/div><\/div><div class=\"clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In this post I am going to explain how to hide admin menu based on system config in Magento 2. In order to add admin menu we write code in menu.xml file, which is located at &lt;vendor&gt;\/&lt;module&gt;\/etc\/adminhtml\/. So now let\u2019s see how you can hide menu based on conditions. Check the below code snippet. &lt;?xml&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/magento\/magento-2-hide-admin-menu-based-system-configuration\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":12038,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[181,59,2138],"tags":[729,2150,9],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11880"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=11880"}],"version-history":[{"count":2,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11880\/revisions"}],"predecessor-version":[{"id":12039,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11880\/revisions\/12039"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/12038"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=11880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=11880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=11880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}