How To Hide Ribbon From Users Without Edit Page Privilege

Ribbon is a great new feature introduced by SharePoint 2010. It provides great user experience for users with elevated privileges, like contributors and site owners. However, for users with lease privilege, such as visitors and anonymous users, it seems like a big waste of page real estate. Because for those users, all ribbon provides are navigation breadcrumb and welcome control (user name with a drop down list on top-right corner).

So I have been asked to figure out a way to remove or hide the ribbon area from user with lease privilege, and here is how:

1) Open your SharePoint master page

2) Locate this line:
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle">

3) Change it to:
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle" style="display:none">

4) Now find the end of the “s4-ribbonrow” tag and add following block right after it:
<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="AddAndCustomizePages">
<script type="text/javascript">
document.getElementById("s4-ribbonrow").style.display = "block";
</script>
</Sharepoint:SPSecurityTrimmedControl>

5) Save the new master page and publish it.

Now when a user without “AddAndCustomizePages” access to view the site, they would not see the ribbon area. You may want to move at least the welcome control to somewhere outside the ribbon area so your lease privilege users can see their user names.

The reason that you have to do it the other way around: make the ribbon invisible (step 3) and make it visible only when users have “AddAndCustomizePages” access (step 4) is the ribbon HTML code has to be rendered to the browser otherwise you would lose some basic abilities on the page, like, to be able to scroll up and down.

Enjoy your page real estate back!

Zewei Song, Ph.D.

MCPD, MCTS: .NET 3.5, MOSS AppDev, Configuration

Enterprise Services, Microsoft Corporation