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;
    // 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?

  • Exactly which property is it complaining about? Feb 4, 2014 at 15:51

1 Answer 1


The IsEnabled method is there to enable the button, the IsAvailable for actually hiding/showing it.

Robert Curlette wrote a nice article about this, see http://www.curlette.com/?p=1117

You can load the details of the current user via:

var user = $models.getItem(Tridion.UI.UserSettings.getJsonUserSettings()["User"]["@ID"]);

But then you will have to ensure the user object is fully loaded, which is not something you can do in an isEnabled or isAvailable method (since you cannot delegate this method to wait for the loading of the User object). However you can access the group membership data directly from the JSON object too:

var membershipIds = "";
var array = Tridion.UI.UserSettings.getJsonUserSettings()["User"]["Data"]["GroupMemberships"];
for (var i = 0; i < array.length; i++) {
    membershipIds += array[i]["@href"] + ",";

Which will give you comma separated String with all TCM URIs of the groups that the current User belongs to.

  • 1
    The boolean parameter to getJsonUserSettings is for synchronous loading. He's already passing in true (=sync), so the settings should be loaded correctly. I'm not sure why it isn't working for him. Feb 4, 2014 at 15:51
  • Thanks for the help! I was using Robert Curlette's approach, though the null check on GroupMemberships was ultimately what was breaking for me. getJsonUserSettings returns "undefined" if a user only has one membership, and an array if multiple memberships. Luckily my case is either admins (no membership) or people with 2 or more, so I was able to loop through the array. Thanks again!
    – kir
    Feb 6, 2014 at 19:58
  • @kir the undefined means you got an object returned (it is not the same as null indeed), which will be the group info that the user is member of. Assign it to a variable and you will be able to see what it is. Indeed it is a bit tricky to work out when it is a single object or an array of objects, my code is expecting multiple groups, so I fell for the same problem again. Feb 7, 2014 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.