SharePoint Online: How to Prevent Users from Editing Pages?

Requirement: Disable the ability to edit site pages in SharePoint Online from site members.

How to Prevent Users from Editing Pages in SharePoint Online?

By default, members of the SharePoint Online site can edit any page in the site including Home page. This creates unnecessary issues at times, and we wanted to stop users from editing site pages. So the overall idea here is: Break permission inheritance of the “Site Pages” library, Edit the permissions of the default members group of the site by Removing “Edit” permissions and add “Read” permissions to them.

Here is the step-by-step procedure to stop users from editing site pages.

  • Browse to your SharePoint site >> Click on Settings Gear >> Choose “Site Contents”
  • Click on “Site Pages” from the list of available lists and libraries.
  • Click on the settings Gear >> Choose “Library Settings”.
  • Under the library settings page, click on “Permissions for this document library”.
  • Now, We have to break permission inheritance. Click on “Stop Inheriting Permissions”.prevent users from editing site pages in sharepoint online
  • Locate and select the checkbox next to the Members Group of the site, in my case its “Operation Site Members” as I’m in the “Operations” site.
  • Click on “Edit User Permissions” button in the ribbon.sharepoint online disable edit page
  • In the edit user permissions page, uncheck the checkbox next to Edit and check it for “Read”.sharepoint online prevent users from editing pages
  • Click on OK button to save your changes.

So now, We have removed edit permissions from members of the site and granted read permissions, so that users won’t be able to edit the page while they still have read access to browse through.

Please note, if the members group has any other permissions like contribute, You have to remove those permissions too!

PowerShell to prevent users from editing pages in SharePoint Online

The above steps can be automated with the help of PowerShell as:

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Operations"
$ListName = "Site Pages"

Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -UseWebLogin

    #Get the Default Members Group 
    $MembersGroup = Get-PnPGroup -AssociatedMemberGroup

    #Break Permission Inheritance of the List
    Set-PnPList -Identity $ListName -BreakRoleInheritance -CopyRoleAssignments

    #Remove "Edit" permission from the list
    Set-PnPGroupPermissions -Identity $MembersGroup -List $ListName -RemoveRole "Edit"

    #Grant "Read" permission to the Group
    Set-PnPListPermission -Identity $ListName -AddRole "Read" -Group $MembersGroup

    Write-Host "Removed 'Edit' Permissions and Granted 'Read' on 'Site Pages' to $($MembersGroup.Title). " -foregroundcolor Green
}
Catch {
    write-host -f Red "Error Setting Permissions!" $_.Exception.Message
}

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply