Search code examples
sharepointsharepoint-2010ribbon

Remove ribbon for Anynonymous Users


I am looking for a way to remove SharePoint Ribbon for anonymous users. Most of the articles I have found talk about SecurityTrimmedControl which hides ribbon but doesnt remove ribbon or related scripts and CSS.

I am looking for a way to not to load Ribbon at all for Anonymous Users.


Solution

  • using client object model u can identify user using below code

     ExecuteOrDelayUntilScriptLoaded(getWebUserData, "SP.js");
     function getWebUserData() {
    context = new SP.ClientContext.get_current();
    web = context.get_web();
    this._currentUser = web.get_currentUser();
    context.load(this._currentUser);
    context.load(web, 'EffectiveBasePermissions');
    context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),   
    Function.createDelegate(this, this.onFailureMethod));
    }
    
    function onSuccessMethod(sender, args) {
    
       // Put your jquery logic for hide ribbon 
    }
    
     function onfaiuremethod(sender, args) {
      alert('Anonymous User');
     }