Skip to main content
3 of 3
edited tags
Bart Koopman
  • 29.6k
  • 3
  • 40
  • 90

How can I disable an SDL Tridion UI extension in the ribbon based on a user group in SDL Tridion 2011?

I was able to hide my extension by accessing the current user's group membership with the following code in the command.js:

MyUIExtensions.MyAlternatePublish.prototype.isAvailable = 
  function MyAlternatePublish$isAvailable(selection) {

var showOption = false;
var groupsWithAccess = ["Publisher"];  // Specify all access groups here

var groups = Tridion.UI.UserSettings.getJsonUserSettings(true).User.Data.GroupMemberships;

if(groups["@title"] == undefined)  // 1 group membership
{
    if(groups.Group["@title"] == groupsWithAccess[0])
        showOption = true;
}
else
{
    // many group memberships
    for (var i = 0; i < groups.length; i++) {
        var userIsInGroup = groups[i]["@title"];
        length = groupsWithAccess.length;
        while(length--) {
           if (userIsInGroup.indexOf(groupsWithAccess[length])!=-1) {
               showOption = true;
               return showOption;
           }
        }
    }
}

return showOption;
};

I am trying to do something similar for the button that appears in the ribbon, and I read that you cannot hide them from the ribbon, and can only disable them. When I attempt to access the user's group membership via Tridion.UI.UserSettings in the IsEnabled method, the console says that this value is not defined.

Does anyone have any suggestion for either hiding/disabling a custom UI extension?

kir
  • 31
  • 1