65.9K
CodeProject is changing. Read more.
Home

Hide SharePoint Top Ribbon for all Users Except Site Collection Administrators

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Jul 6, 2016

CPOL
viewsIcon

12571

How to hide Sharepoint designer ribbon for all users except site collection administrator

Introduction

This tip will help you to hide the top ribbon on the Sharepoint site collection.

  1. Navigate SharePoint Site and click Sit Settings from Setting Menu
  2. Click Master Pages and Page Layouts link in Web Desginer Galleries section
  3. Download seattle.html page
  4. Make the following changes in the masterpage code

Add the below code before s4-workspce div " <div id="s4-workspace" class="ms-core-overlay">"

The JavaScript code document.getElementById("ms-designer-ribbon").style.display = "block";
will be executed only if the logged on user is site collection administrator, because we set the permission string value as "FullMask". If you want to hide the menu only for anonymous user, then change the PermissionString as AnonymousUsersOnly. The permission string possible values are given below:

 <!--MS:<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" 
    runat="server" PermissionsString="FullMask">-->
            <script type="text/javascript">//<![CDATA[

        document.getElementById("ms-designer-ribbon").style.display = "block";
   
            //]]>
            </script>
        <!--ME:</Sharepoint:SPSecurityTrimmedControl>-->

History

  • 5th July, 2016 - Initial version created