Wednesday, March 7, 2012

Hide SharePoint 2010 Ribbon for Read/View users

The SharePoint 2010 Ribbon is a very good feature, but in some case you need to hide the ribbon from users who does not have access to edit the page. Here you can hide ribbon from users who does not have edit access by modifying in the master page in SharePoint 2010.

First take a backup for your v4.master page and open in SharePoint Designer.

After taking the backup, now check out the master page and search for <div class="s4-title s4-lp"> and replace this with <div class="s4-title s4-lp" id="HeaderNavID" style="display:none">.
We have given one id property which is id="HeaderNavID" and one style property which is style="display:none"

Now go to the close
</div> tag of the above div <div class="s4-title s4-lp" id="HeaderNavID" style="display:none"> and place the below code
<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="AddAndCustomizePages">
<script type="text/javascript">
document.getElementById("HeaderNavID").style.display = "block";
</script>
</Sharepoint:SPSecurityTrimmedControl>

Happy SharePointing!!!

No comments:

Post a Comment