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

Is it possible to hide specific buttons of the SharePoint 2010 Ribbon Bar based on the user's permission on publishing pages? For example, we need to hide the font dropdown and under the Insert tab, hide the Web Parts button; we only want to show these items to the members of the custom IntranetAdmin SharePoint security group.

This article covers how to hide an entire tab: http://johanolivier.blogspot.com/2011/12/show-or-hide-sharepoint-ribbon-tab.html

Anyway to do this for individual buttons based on the user's permission on publishing pages?

Thank you.

share|improve this question

3 Answers 3

up vote 9 down vote accepted

You can use the SPRibbon.TrimById(controlId) method to hide controls. http://msdn.microsoft.com/en-us/library/microsoft.web.commandui.ribbon.trimbyid.aspx

This page lists the controlIDs: http://msdn.microsoft.com/en-us/library/ee537543.aspx

You can use other OM methods to determine the user's permission and call the TrimById method accordingly. For example, you could use DoesUserHavePermissions on the page's list item: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurableobject.doesuserhavepermissions.aspx

share|improve this answer

This product actually allows you to hide or disable buttons (based on SharePoint permissions) on the Ribbon panel: http://www.xstreamsoftware.com/Sharepointribbonizer.htm

share|improve this answer
    
Please don't post identical answers - there is a fine line between helping other users and promoting a product. Please see May I promote products or websites I am affiliated with here? for guidelines. –  SPDoctor Mar 22 '13 at 18:58

You can try using Jquery and CSS for this purpose too and add it in your master page.

  1. Add the script for including the Jquery file and include the following code to get the group name of the person logged in.

<script type="text/javascript" src="/Jquery/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/Jquery/jquery.SPServices-0.6.2.min.js"></script>

var groupName;
 $().SPServices({ 
    operation: "GetGroupCollectionFromUser", 
    userLoginName: $().SPServices.SPGetCurrentUser(),
    async: false,
    completefunc: function(xData, Status) { $(xData.responseXML).find(["nodeName=Group]").each(function() {groupName = $(this).attr("Name");}); } });    
if($.trim(groupName) != 'IntranetAdmin') 
{
    ///CSS to hide the ribbon style should go here..
}

2. Example of hiding the ribbon control in CSS looks like this

#Ribbon\.ListItem\.New\.NewListItem-Large
{
    display:none;
} 

3. Integrating both should get you the result easily without coding.

share|improve this answer
    
Nice one Deepu. I just tried your code but i don't get anything back:( –  naijacoder May 3 '12 at 2:28

Your Answer

 
discard

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

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