API Reference: EditableForAttribute Class

The EditableForAttribute can be applied to content model properties. The attribute restricts edit authorization for this property to the specified user groups. It does not add edit authorization for user groups that don't have it in the first place. The property will be read-only for any user that is not part of at least one of the provided user groups.

If EditableForAttribute is not specified, the property is editable by any user that has edit permissions on the content item through regular authorization settings.

This attribute allows system administrators fine-grained access control on individual content properties, in addition to the regular content permissions. Regardless of this attribute, a user also requires edit permissions for the content as a whole.

Usage

Decorate the content model property with the EditableForAttribute. The attribute constructor accepts one or more user group names as a params string[] parameter. Alternatively, the attribute can be set multiple times on the property.

The user group names are case insensitive. Passing non-existing user groups does not cause an error. Whenever a user group name is changed, these names will have to be updated if used with this attribute as well.

Example

[Page]
public class ContentPage: IContentType
{
    // Editable by any user who has edit permissions for this content.
    public string PageTitle { get; set; }

    // Only editable for members of either the Editors or Administrators group. Read-only for all other users.
    [EditableFor("Editors", "Administrators")]
    public bool HideInNavigation { get; set; }

    // Only editable for members of the Administrators group. Read-only for all other users.
    [EditableFor("Administrators")]
    public bool EnableSearchIndexing { get; set; }
}