Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Hide or control access to customized components

Describes how to manage access to customized components in the Optimizely Content Management System (CMS) user interface.

The AllowedRoles property for component definitions lets you control the groups 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 component, depending on a global setting.

[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
    };

    AllowedRoles.Clear();
    AllowedRoles.Add("none");
  }
}