Sitecore non administrator user show hidden items

sitecore

Solution

This information is retrieved by `Sitecore.Shell.UserOptions.View.ShowHiddenItems` property which gets this data from `UserProfile` (or from `RegistryCache` if the profile was already loaded).

User profile information is stored for every user separately and saved in database in binary column. There is no way of getting this option from user role.

Still you can write a script that will loop through all users in the role you mentioned and set the value in profile of those users:

public static void SetHiddenItemsValue(User user)
{
    string key = "/Current_User/UserOptions.View.ShowHiddenItems";
    string value = "true";

    if (!(user != null))
        return;
    key = StringUtil.Left(key, 250);
    key = key.Replace("Current_User", user.Name);
    user.Profile[key] = value;
    user.Profile.Save();
    RegistryCache registryCache = CacheManager.GetRegistryCache(Sitecore.Context.Site);
    if (registryCache == null)
        return;
    registryCache.Clear();
}

Problem

I have created some Sitecore users who are not administrators and assigned them few roles. When these users access the Sitecore portal as default they are not shown hidden items and they have to go to view tab and configure it manually. Is there a way I can configure these users to view hidden items by default by doing some configurations to a user role shared between these users.

Original source