Usergroup Hooks / dynamic permissions.

Status
Not open for further replies.

Trekkan

OMG Member
Joined
Jan 11, 2009
Messages
4
Basically, I need to dynamically create different permissions in usergroups.

What I need to do is when a usergroup is edited, I need to read data from an external source and then dynamically add/remove permissions to a group that is already created.

Adding in new permissions shouldn't be a problem, the table syntax is pretty straightforward. What I'm looking for are any hooks that I can tie into when a usergroup is edited. If that exists (hopefully it does), then when it's fired, I'll fire off my code to update things appropriately and then the new perms will be displayed on the usergroup edit screen.

Thanks for any information you can provide.
 

Fuhrmann

OMG Member
Joined
Oct 27, 2011
Messages
93
Hey Trekkan!

I looked and I think the only solution for you is extend the XenForo_DataWriter_UserGroup::_postSave().

Everytime a usergroup is edited this function is called.

Then, inside this function, you can use the XenForo_Model_Permission to get permissions from a group using the function getAllPermissionsWithValues so you can pass the UsegroupId or/and the UserID.

Code:
getAllPermissionsWithValues($userGroupId = 0, $userId = 0)

With this way, you will be able to edit permissions selecting then based in the usergroupID existing that you want to change and them after selecting, you can create a instance of the XenForo_DataWriter_PermissionEntry (not sure about this one) and save the values...
 
Status
Not open for further replies.
Top