Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to hide the "Sign In as Different User" option on the "Welcome" menu for all users. This is for SharePoint 2010. I have tried adding a customaction feature using the xml below, which didn't work. I heard a rumor that this is a known issue, so I then tried adding the javascript below to the bottom of the body tag in v4.master.

The HideCustomAction does not seem to work for any of the Welcome menu items, but the javascript works fine for "PersonalizePage" and "PersonalInformation," which I am also hiding. I have condidered jQuery, but suspect it might have the same issue, which is the inability to consistently find the "LoginAsDifferentUser" menu item.

The only thing I saw work was putting the javascript into a CEWP, but it worked the first time I tried it, then quit working.

Any help is greatly appreciated. TIA

Elements.xml:

<HideCustomAction
    GroupId="PersonalActions"
    Id="LoginAsDifferentUser"
    Location="Microsoft.SharePoint.StandardMenu">
</HideCustomAction>

javascript:

<script type="text/javascript">
    var objects = document.getElementsByTagName("ie:menuitem");
    for (var i = 0; i < objects.length; i++) {
       itm = objects[i];
       if (itm.id.match("LoginAsDifferentUser") != null) {
           var parentNodeOfMenuItem = itm.parentNode;
           parentNodeOfMenuItem.removeChild(itm);
       }
    }
</script> 
share|improve this question
1  
Much thanks to everyone who responded. Here is the final solution to hide the "My Settings, "Signin as a Different User," and ""Personalize this Page" menu items. Works in every browser I have checked. jQuery(document).ready(function($){ $("[text='Sign in as Different User']").remove(); $("[text='My Settings']").remove(); $("[text='Personalize this Page']").remove(); }); –  user2255 Jan 26 '11 at 22:42

2 Answers 2

up vote 1 down vote accepted

This is where I wish I was more of a jQuery developer and less of a hack... I couldn't get jQuery to return the ie:menuitem tags to iterate over so I had to use javaScript to get them.. However, I was able to hack together a solution for you.

Maybe someone can come up with something more elegant, but this works:

jQuery(document).ready(function($){

 var objects = document.getElementsByTagName("ie:menuitem");    
 for (var i = 0; i < objects.length; i++) {       
    itm = objects[i];
    if ($('#' + itm.id).attr("text") == "Sign in as Different User")
    {
        $('#' + itm.id).remove();
    }
}

})
share|improve this answer
2  
Probably something like the following then: jQuery(document).ready(function($){$("[text="Sign in as Different User]").remove()};); –  Neil Richards Jan 26 '11 at 21:39
    
Neil's "elegant" solution was almost perfect. (The double quote before Sign needed to be a single quote and a single quote neded to be added after User.) Thank you both so much for responding. (Now I have to figure out if I can justify billing 15 hours for this solution since that is how many hours I have beaten my head against the wall on this. LOL) –  user2255 Jan 26 '11 at 22:41

Did you debug the Javascript to see why it wouldn't find the menu item?

I'd recommend using jQuery, as it will almost always find the element you want, provided you structure the selectors properly.

share|improve this answer
    
I used the exact same javascript to hide the PersonalizePage and PersonalInformation menus. They worked perfectly, so I think the javascript is good. It's just the LoginAsDifferentUser menu that seems to give me problems. I tried to translate the javascript to the equivilant jQuery, but I am not familiar enough with it to get it to work. Thanks for responding. –  user2255 Jan 26 '11 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.