I am in a need to hide the Site Content option completely from site for Visitors. Can anyone help me how I can achieve this goal?
How to hide Site Content only for Visitors or a particular security group in SharePoint 2013?
I am in a need to hide the Site Content option completely from site for Visitors. Can anyone help me how I can achieve this goal?
How to hide Site Content only for Visitors or a particular security group in SharePoint 2013?
You have two possibilities in this case that doesn't require code.
Variant 1) Change the permission level of visitor When you change the permission level from "Read" to "Restricted Read" your user won't see the site contents anymore
Variant 2) Alternate read permission level of visitors You can simply remove the base permission "View Application Pages" from the "Read" Permission level.
The "site contents" is not the only place where user will see this navigation option. It is also available through the gear icon on the suite bar. By changing the permissions or permission level it will be hidden from there too.
You'd have to remove it from 2 places, the Quick Launch and the Site Actions menu. You can use JQuery and SPServices to check group membership and hide the link in the Quick Launch. Put the code in your master page(s), not a Content Editor Web Part, to hide it on the entire site. You can also use JQuery to hide "View All Site Content" from the Site Actions menu.
However, you will not be able to prevent users from typing /_layouts/viewlsts.aspx
directly into the address bar. Clicking the default "Lists" or "Libraries" headers in the Quick Launch would also take them to the content page. It might be possible to add JQuery to the system master page to redirect visitors to a different page if the URL includes /_layouts/viewlsts.aspx
.
Usually your visitors won't go to many pages, so the CEWP option works fine.
Note: If they know the URL they can go where they have rights
So it is kind of pointless to hide it; they should only see what they are allowed to see inside "Site Contents"
What you do usually when you have an internet publishing site is to include a SPSecurityTrimmedControl on your masterpage, to restrict the real visibility of the control (here the quicklaunch) for different users.
An other solution is to restrict the link directly on the link itself. When you see the control in the masterpage, you have properties like PermissionsString="ViewFormPages".
The control for the link in the masterpage (seattle.master)
<SharePoint:ClusteredSPLinkButton
runat="server"
id="idNavLinkViewAll"
PermissionsString="ViewFormPages"
NavigateUrl="~site/_layouts/15/viewlsts.aspx"
Text="<%$Resources:wss,AllSiteContentMore%>"
accesskey="<%$Resources:wss,quiklnch_allcontent_AK%>"
CssClass="ms-core-listMenu-item ms-core-listMenu-heading" />
You can change the permissionstring to "ManageWeb" to restrict the link to the admin.
For both solution, you should update the masterpage, with SP Designer e.g
Regards,
ps : Don't forget to NOT update standard masterpage but make a copy before and work on this copy :)
SharePoint Online doesn't handle the permissions at the same way as SharePoint 2013.
Use this:
<SharePoint:SPSecurityTrimmedControl runat="server" Permissions="AddListItems"
PermissionContext="CurrentItem" PermissionMode="Any">
<SharePoint:MenuItemTemplate runat="server" id="MenuItem_ViewAllSiteContents"
Text="<%$Resources:wss,quiklnch_allcontent_15%>"
Description="<%$Resources:wss,siteactions_allcontentdescription%>"
ImageUrl="/_layouts/15/images/allcontent32.png?rev=43"
MenuGroupId="200"
Sequence="240"
UseShortId="true"
ClientOnClickNavigateUrl="~siteLayouts/viewlsts.aspx"
PermissionsString="ViewFormPages"
PermissionMode="Any" />
</SharePoint:SPSecurityTrimmedControl>