How can I hide ribbon for anonymous users in SharePoint 2013? I also want to make sure anonymous users can not see Site Contents page.

3 Answers 3


You can get the user name with this javascript:

    function fxGetUserName()
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
var xUser = web.get_currentUser();
ctx.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded(sender, args)

function onQueryFailed(sender, args)
alert('request failed ' + args.get_message() + '\n'+ args.get_stackTrace());

then figure out if it is anonymous or not and hide the ribbon with this function for example:

function fxHideRibbon() {


  • I wouldn't leave those embedded alerts. :) Commented Apr 15, 2015 at 23:54

Per the following TechNet article,

You might have thought to hide Ribbon from the Anonymous users due to security reason.

In SharePoint 2010 it was simple to modify the master page and that's done, In SharePoint 2013 there has been some changes and we no more need to modify the master page directly, every thing is simplified in 2013 and we just need to modify the concern html page and that should be done.

Every master page in 2013 would have it concerned html page e.g. for Seattle.master, we have Seattle.html. Respectively, for oslo.master, we have oslo.html page which in turn controls the master page and its tags.

The HTML page has tags that start with <!--MS:--> and <!--ME:--> that show markup inside these tags and in some cases what you would find in the final corresponding master page.

So lets get to the action on what need to done in these html page.

  1. Open the html page in SharePoint Designer 2013 or open the site through explorer and open it using your favorite HTML page editor.

  2. Look for <div class ="ms-belltown-anonshow">

    <div id="ms-designer-ribbon"> ... </div >

  3. When we add the following markup enclosed in the <!--MS:--> and <!--ME:—> tags,

<!—MS:<SharePoint:SpSecurityTrimmedControl runat="server" permission="AddandCustomizepages">—> <div class="ms-belltown-anonshow"> <div id=”ms-designer-ribbon”> ... </div> <!—MS:</SharePoint:SpSecurityTrimmedControl>—>

the design manager will create the corresponding master page with the correct functionality of hiding the Ribbon for an anonymous user.

For list of permission you can refer to http://msdn.microsoft.com/en-ca/library/microsoft.sharepoint.spbasepermissions.aspx


You can hide ribbon in SharePoint 2013 using below mentioned cod. It can be applied to master page which you are using for the site.

<SharePoint:SPSecurityTrimmedControl runat="server" AuthenticationRestrictions="AuthenticatedUsersOnly" EmitDiv="true">
 <div id="suiteBar" class="ms-dialogHidden noindex">
   <!--#suiteBarLeft and #suiteBarRight-->
 <div id="s4-ribbonrow">
  <!--ootb ribbon controls-->

Find controls of ribbon & suite bar & hide them from anonymous users as per the need.

For Site Content Link

You can find the control like

  accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>" />

add the AuthenticationRestrictions="AuthenticatedUsersOnly" befor the end of the tag "/>".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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