<p>Try using <code>accessSiteWhenSystemIsOff</code>.  If you're on a case-sensitive file system, that will matter.</p>

<blockquote>
  <p>does anyone know if it's possible to set a group permission that gives access to a plugin</p>
</blockquote>

<p>You'll want a plugin for that. You can use the <a href="http://buildwithcraft.com/docs/plugins/hooks-reference#registerUserPermissions" rel="nofollow">registerUserPermissions</a> hook to register a custom permission.</p>

CC BY-SA 3.0
2015-03-18T17:02:47.243Z
2015-03-18T17:02:47.243Z
Brad Bell
<p>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:</p>

<pre><code>craft()-&gt;userPermissions-&gt;saveGroupPermissions($group-&gt;id, array("accesssitewhensystemisoff"));
</code></pre>

<p>The string <code>accesssitewhensystemisoff</code> 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.</p>

<p>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? </p>

<p>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?</p>

<p>Thanks!</p>

<plugin-development><user-groups><permissions><group>
Save Group Permissions
# Save Group Permissions

(Asked by: username_0 on 2015-03-18)

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!

**Tags:** plugin-development, user-groups, permissions, group

---

## 1 answers

### Answer by username_1 on 2015-03-18. Score: 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](http://buildwithcraft.com/docs/plugins/hooks-reference#registerUserPermissions) hook to register a custom permission.


---

