none
Hide Ribbon for site Visitors (Read) ONLY - AddAndCustomizePages

    Question

  • Hi all,

    I am using SharePoint Foundation 2010. I have created a custom masterpage for an intranet. By default, there are 3 user groups created after installation:

    Sites Owners - Full Control

    Site Members - Contribute

    Site Visitors - Read

    I need to hide the ribbon from all of those with just Read only access (i.e. the visitors). I have hidden the ribbon by default using:

    	<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="AddAndCustomizePages">
    		<script type="text/javascript">
    		document.getElementById("s4-ribbonrow").style.display = "block";
    		</script>
    	</Sharepoint:SPSecurityTrimmedControl>

    This works fine for me as a Site Owner, and I can see the ribbon. I then set-up a few test accounts, put some in Site Members and some in Site Visitors - the ribbon was hidden for all of these users, regardless of the group. This got me Google'ing and I tried changing the PermissionsString to ManageLists, AddListItems etc - something that a Member (Contribute) user should be able to do. But it still will not show for them.

    My question is - how can I just hide the ribbon from the Read users? And allow Contribute, Design, Full Control to have it?

    Thanks.

    Friday, March 9, 2012 3:48 PM

Answers

  • Thanks for the reply, I have had a look at that already.

    If I understand this correctly, a collection of those member names will form a permission group (Contribute or Read). 

    Assigning one of those should allow that user group (i.e. AddListItems is definitely a Contributor action) to view the ribbon. So by using the code:

    	<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="AddListItems">
    		<script type="text/javascript">
    		document.getElementById("s4-ribbonrow").style.display = "block";
    		</script>
    	</Sharepoint:SPSecurityTrimmedControl>
    a Contribute user should see the ribbon...but they do not. Any ideas why? If I need to include a series of PermissionStrings, what ones map to a Contribute user, and what to a Design, Full Control, Read etc.
    • Marked as answer by cmatt727 Tuesday, March 13, 2012 3:56 PM
    Friday, March 9, 2012 4:02 PM

All replies

  • Here you can find an overview of the SPBasePermissions Enumeration http://msdn.microsoft.com/EN-US/library/ms412690

    with the property "PermissionsString" you can give more rights by separating them with a comma.

    Hopes this helps.


    /blog twttr @esjord

    Friday, March 9, 2012 3:57 PM
  • on codeplex is also a nice solution http://spribbonvisibility.codeplex.com/

    /blog twttr @esjord

    • Marked as answer by GuYumingModerator Monday, March 12, 2012 6:47 AM
    • Unmarked as answer by cmatt727 Tuesday, March 13, 2012 10:24 AM
    Friday, March 9, 2012 4:00 PM
  • Thanks for the reply, I have had a look at that already.

    If I understand this correctly, a collection of those member names will form a permission group (Contribute or Read). 

    Assigning one of those should allow that user group (i.e. AddListItems is definitely a Contributor action) to view the ribbon. So by using the code:

    	<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="AddListItems">
    		<script type="text/javascript">
    		document.getElementById("s4-ribbonrow").style.display = "block";
    		</script>
    	</Sharepoint:SPSecurityTrimmedControl>
    a Contribute user should see the ribbon...but they do not. Any ideas why? If I need to include a series of PermissionStrings, what ones map to a Contribute user, and what to a Design, Full Control, Read etc.
    • Marked as answer by cmatt727 Tuesday, March 13, 2012 3:56 PM
    Friday, March 9, 2012 4:02 PM
  • I'm unfamiliar with what you are wrapping inside the securitytrimmedcontrol. When I place the SPRibbon control from V4 master inside the master page it works as expected, readers cannot see the ribbon but contributors and owners can.

    Sparkytect
    MCITP SharePoint 2010
    MCPD SharePoint 2010
    MCT SharePoint 2010
    MCC SharePoint 2010
    SPForDummies.com

    Friday, March 9, 2012 4:31 PM
  • <div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle" style="display:none">

    Set the ribbon to display:none by default. Then if the user is an Owner or Contributer, display:block;

    Do you mean you placed the entire ribbon control in the SecurityTrimmedControl?

    Friday, March 9, 2012 4:41 PM
  • it won't work if you put the code before the <div id="s4-ribbonrow">

    it works if you put the code after that tag

    Monday, March 12, 2012 6:47 AM
    Moderator
  • Hi GuYuming,

    This code is after the <div id="s4-ribbonrow"> and the entire ribbon control.

    Any other suggestions?

    Tuesday, March 13, 2012 9:04 AM
  • check if javascript is enabled in your browser in IE->internet options->security tab.
    Tuesday, March 13, 2012 9:47 AM
    Moderator
  • Yes - JavaScript is enabled. If you re-read my original post, the issue isn't that it's not working at all, rather that it is not working as intended (showing for only Full Control users).

    Any ideas? Someone out there must have done this for an intranet.


    • Edited by cmatt727 Tuesday, March 13, 2012 10:25 AM
    Tuesday, March 13, 2012 10:24 AM
  • HI 

    For SharePoint 2013, the below code will hide the ribbon from Visitor permissions user.

    http://www.richardjoosten.com/Blog/Bericht/3/Hide-the-SharePoint-2013-ribbon-for-visitors,-and-keep-scroll-functionality

    Thanks.

    • Proposed as answer by Sagusara Wednesday, August 17, 2016 4:48 AM
    Wednesday, August 17, 2016 4:48 AM