12

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.

3 Answers 3

10

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

3

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.

2
  • Nice one Deepu. I just tried your code but i don't get anything back:( Commented May 3, 2012 at 2:28
  • Very Helpful, indeed! Commented Feb 23, 2015 at 15:34
1

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

1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.