Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
1 like 0 dislike
7k views
in SharePoint Server by 66 69 85
edited by

I'm attempting to restrict access for site contents to users in the SharePoint Visitors group without removing the possibility for them to see pages. Currently, when adding a user to the Visitors group, he can access not just pages but also Site Content in the Site Setting menu. How can I hide site contents from users in the Visitors Group and Read permission in SharePoint 2019?

hide site contents


1 Answer

0 like 0 dislike
by 163 203 401

Hide Site Contents from Visitors in SharePoint 2019?

As you know, the SharePoint Visitors group has Read Permission by default, and to hide the Site Contents option from the Site Setting List, you have to do the following:

  1. Open Site Collection > Click on the Settings Gear icon, then Click on Site Settings.
  2. Under Users and Permissions, Click on Site Permissions.
    Hide Site Contents from Visitors in SharePoint 2019
  3. From the above ribbon, click on Permission Levels.
    Manage permission levels in SharePoint 2019
  4. Click on the Read Permission Level to edit it.
    Edit read permission in sharepoint 2019

    It's preferred to copy the Read permission level and create a new one with your new customization, then create a new group with the new permission level.

  5. Uncheck "View Application Pages - View forms, views, and application pages. Enumerate lists.", then click Ok.
    View Application Pages  -  View forms, views, and application pages. Enumerate lists.
  6. Try now to log in to your site with a user in the visitor's group, and you will note that the Site Contents is now removed based on the user permission.

See also How to Get SharePoint Folder Permissions Using JavaScript?


Hide Site Contents from Visitors in SharePoint using CSS?

If you want to provide the View Application Pages rights to allow the user to view the InfoPath and other forms while also removing the Site Contents menu item, you have to do that using the CSS code below.

For the SharePoint classic experience, you can add the below CSS either to your master page to apply it on all sites or using script editor web part to apply it for specific page

<style>
span.ms-splinkbutton-text {
 Display:none!important;
}
 
#sideNavBox a[href$="/_layouts/15/viewlsts.aspx"] {
    display: none;
 }
</style>

You can also use the below one

 <style>
    a#O365_SubLink_SuiteMenu_zz6_MenuItem_ViewAllSiteContents {
    display: none;
   }
 </style>

For SharePoint Online Modern Team sites, you can the below CSS to remove site contents:

<style>
.ms-Nav-navItem a[href$="/_layouts/15/viewlsts.aspx"] {
         display: none;
 }
</style>
If you don’t ask, the answer is always NO!
...