Hi, is there is a way to enforce this checkbox value = true each user login ? If enforce not possible, can we globally set check = true for each users?
I found similar question here: Set Default Value of Ribbon Checkbox and make some adjustment since it have different settings and sitecore version as follow
using Sitecore.Diagnostics;
using Sitecore.Pipelines.LoggedIn;
using Sitecore.Security.Accounts;
namespace CustomLogin
{
public class EnforceEntireTree
{
public void Process(LoggedInArgs args)
{
User user = User.FromName(args.Username, true);
Assert.IsNotNull(user, "user");
user.Profile.SetPropertyValue("/Content Editor/Ribbons/Chunks/View/Entire Tree", "on");
}
}
}
When it's executed it's throw error: "The settings property '/Content Editor/Ribbons/Chunks/View/Entire Tree' was not found."
UPDATE:
I found proper name for that setting but these code isn't working
namespace CustomLogin
{
public class EnforceEntireTree
{
public void Process(LoggedInArgs args)
{
User user = User.FromName(args.Username, true);
Assert.IsNotNull(user, "user");
string key = "/" + user.Name + "/UserOptions.View.ShowEntireTree";
user.Profile.Initialize(user.Name, true);
user.Profile[key] = "true";
user.Profile.Save();
}
}
}
UPDATE #2: After Andrey Bobrov said, i try to clear cache by using this way:
namespace CustomLogin
{
public class EnforceEntireTree
{
public void Process(LoggedInArgs args)
{
User user = User.FromName(args.Username, true);
Assert.IsNotNull(user, "user");
string key = "/" + user.Name + "/UserOptions.View.ShowEntireTree";
user.Profile.Initialize(user.Name, true);
user.Profile[key] = "true";
user.Profile.Save();
RegistryCache registryCache = CacheManager.GetRegistryCache(Context.Site);
registryCache.Clear();
}
}
}
Still not working, Do I doing it wrong? If I clear all the cache from sitecore/admin/cache.aspx then the checkbox is checked just by using refresh (F5)
Thank You