Changing system permissions programmatically

Hi! I’d like to change permissions programmatically, which are set in /dashboard/system/permissions/users and /dashboard/system/permissions/tasks. Is this possible?

I have a package that creates new user groups, and I need to give them access to sitemap and member dashboard pages.

There aren’t a lot of examples here, but this document page might help.

Thanks! I’ve used this tutorial for permissions before, but at first I could’nt figure out how to use it for sitemap or member permissions.

But now I found example from Concrete\Core\Package\StartingPointPackage.php and found a correct way to do it:

$group = Concrete\Core\User\Group\Group::getByName('Group Name');
$entity = Concrete\Core\Permission\Access\Entity\GroupEntity::getOrCreate($group);
$pk = Concrete\Core\Permission\Key\Key::getByHandle('access_sitemap');
$pa = Concrete\Core\Permission\Access\Access::create($pk);
$pt = $pk->getPermissionAssignmentObject();

Had to do some searching to find all the permissionkey handles, but found them on concrete/config/install/base/permissions.xml.

1 Like