8.4+ How to remove guest permissions for page?
Permalink
I need to set permissions to view a page only by a certain group. I guess I have to remove guest permissions from that page and add group permissions:
But this code removes guest permissions for ALL pages, not just my_page. What's wrong here?
Thank you.
$page = Page::getByPath('/account/my_page'); if (is_object($page) && !$page->isError()) { $key = PermissionKey::getByHandle('view_page'); $key->setPermissionObject($page); $access = $key->getPermissionAccessObject(); if ($access) { $entity = GroupEntity::getOrCreate(Group::getByID(GUEST_GROUP_ID)); $access->removeListItem($entity); } $page->assignPermissions($group, ['view_page']); }
But this code removes guest permissions for ALL pages, not just my_page. What's wrong here?
Thank you.
Here it is: