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

Hide or control access to customized components

Use the AllowedRoles property to restrict which user groups see a component in CMS 13.

Restrict component visibility to specific user groups with the AllowedRoles property on component definitions. Set AllowedRoles to "none" to hide a component from all users. Set it to a null string to skip the access check entirely.

The following example hides the file management component from all users:

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

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