Friday, September 21, 2012

Hide Ribbon from Read Access users in SharePoint 2010


Ribbon is a very good feature provided by SharePoint 2010. 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 open your master page in SharePoint designer 2010 and also take a backup for your master page. Remember we are going to modify in the v4.master page.

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>

If you want to learn something about SPSecurityTrimmedControl then you can see this Article.

For more information you can see this blog also which I followed. http://blogs.msdn.com/b/zwsong/archive/2010/04/29/how-to-hide-ribbon-from-users-without-edit-page-privilege.aspx

No comments:

Post a Comment