Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

The AllowedRoles property for a component definitions lets you control the groups that are allowed to view and select a certain component. You can hide a component completely by setting the AllowedRoles property to none, or setting it to a null string which prevents an access check.

The following example shows how to hide or show a certain component, depending on a global setting.

C#
[Component]
    public class FileManagementComponent : ComponentDefinitionBase
    {
        public FileManagementComponent()
            : base("epi-cms.component.FileManagement")
        {
            Categories = new string[]{"cms"};
            LanguagePath = "/episerver/cms/components/filemanagement";
            SortOrder = 200;
            PlugInAreas = new string[] { PlugInArea.DefaultAssetsGroup };

            if (!EPiServer.Configuration.Settings.Instance.UseLegacyFileManagerMode)
            {
                AllowedRoles.Clear();
                AllowedRoles.Add("none");
            }
        }
    }
}
Do you find this information helpful? Please log in to provide feedback.

Last updated: Sep 21, 2015

Recommended reading