1

I need to hide the ribbon from anonymous users, but I want them to see the other part of the website as normal, just without ribbon.

I researched this topic and found a lot of examples like

  • SPSecurityTrimmedControl
  • some javascript methods and CSS tricks

What is the best way of doing this?

0

Eric Overfields article Hide the SharePoint Online Ribbon for Anonymous Users explains the topic very well (it works the same way for on-premise):

The often quoted, yet incorrect, solution for hiding the SharePoint ribbon for anonymous users is to encapsulate the entire suite bar / ribbon with the SPSecurityTrimmedControl with AuthenticationRestrictions set to AuthenticationRestrictions. The problem with this solution is that the out-of-the-box SharePoint JavaScript that is used to determine the height of the s4-workspace requires a div with an id, s4-ribbonrow.

My preferred SharePoint Online and SharePoint 2013 solution for hiding the suite bar / ribbon for anonymous users uses the above theory while also addressing the #s4-ribbonRow requirement. I also find is much cleaner than what is found in the oslo master page.

Simply replace the suite bar / ribbon found in your master page with the following:

<div id="ms-designer-ribbon">
   <SharePoint:SPSecurityTrimmedControl runat="server" AuthenticationRestrictions="AnonymousUsersOnly" EmitDiv="true">
      <div id="s4-ribbonrow" style="visibility:hidden;display:none"></div>
   </SharePoint:SPSecurityTrimmedControl>
   <SharePoint:SPSecurityTrimmedControl runat="server" AuthenticationRestrictions="AuthenticatedUsersOnly" EmitDiv="true">
      <div id="suiteBar" class="ms-dialogHidden noindex">
         <!--#suiteBarLeft and #suiteBarRight-->
      </div>
      <div id="s4-ribbonrow">
         <!--ootb ribbon controls-->
      </div>
   </SharePoint:SPSecurityTrimmedControl>
</div>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.