How to remove the “My Settings” from the menu in edit mode

  • Updated

The following are three different ways to remove "My settings" from the menu in edit mode:

1.By code:

public class CustomMenuAssembler : MenuAssembler
{
public CustomMenuAssembler(IMenuProvider[] menuProviders, IServiceLocator container) : base(menuProviders,

container)
{ }
public override IEnumerable<MenuItem> GetMenuItems(string parentPath, int relativeDepth)
{

var menuItems = base.GetMenuItems(parentPath, relativeDepth).ToList();

var settingsItems =
menuItems.Where(x => x.Path.StartsWith("/global/user/settings", StringComparison.Ordinal)).ToList();

if (!settingsItems.Any())
{
return menuItems;
}

// Add user group check here

foreach (var settingItem in settingsItems)
{
menuItems.Remove(settingItem);
}
return menuItems;
}
}

//And registering the new menu assembler:

[InitializableModule]
public class CustomMenuInitialization : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.ConfigurationComplete += (o, e) =>
{
context.Services.AddSingleton<MenuAssembler, CustomMenuAssembler>();
};
}

public void Initialize(InitializationEngine context) { }

public void Uninitialize(InitializationEngine context) { }

public void Preload(string[] parameters) { }

}

 

2. Add location section in web config to deny permissions
<location path="EPiServer/Shell/Settings">
    <system.web>
      <authorization>       
        <deny users="*" />
      </authorization>
    </system.web>
  </location>

3.
Remove the file MySetting.aspxs from the zip in the path below and put somewhere outside the web folder for future reference.
webfolder\modules\_protected\CMS\CMS.zip\Edit\MySettings.aspx