0

I'm trying to programmatically set group permissions. I came across the method saveGroupPermissions(). According to the documentation all you have to do is pass in the group ID and then an array of the permissions you want to apply. Great, seems simple enough. So I attempted the following:

craft()->userPermissions->saveGroupPermissions($group->id, array("accesssitewhensystemisoff"));

The string accesssitewhensystemisoff is a built-in Craft permission, I'm not attempting to set my own custom permission... Not even sure if that's possible but we'll save that discussion for later.

Anyway this is not working and I have no idea why. There are literally zero examples of how to properly do this so I'm wondering if anyone else has solved this problem?

On a related note does anyone know if it's possible to set a group permission that gives access to a plugin? Or do I need to whip up my own plugin to handle that?

Thanks!

1

Try using accessSiteWhenSystemIsOff. If you're on a case-sensitive file system, that will matter.

does anyone know if it's possible to set a group permission that gives access to a plugin

You'll want a plugin for that. You can use the registerUserPermissions hook to register a custom permission.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.