1. We would like to create a userlist that contains everyone who either owns or is an admin and a moderator of a Groupjive group. How can we configure this?
You'll need to add an advanced filter to your userlist to filter the userlist down to users of that group and of a specific status. Example as follows.
Code:
( SELECT COUNT(*) FROM `#__groupjive_users` AS gj WHERE gj.`user_id` = u.`id` AND gj.`status` >= 1 AND gj.`group` = GROUP_ID_HERE ) >= 1
Replace GROUP_ID_HERE with the ID of the group you want to check against. gj.`status` >= 1 is checking if they're approved in the group, but you can adjust this to gj.`status` >= 2 to return moderators and above. The statuses are as follows.
-1 = Banned
0 = Pending
1 = Member
2 = Moderator
3 = Admin
4 = Owner
2. We have an access level for owners, another for admins and another for moderators of groups and we would like an auto action that will add and remove users to and from these user groups when they are promoted or demoted in groupjive.
Create a usergroup action acting on gj_onAfterUpdateUser and gj_onAfterCreateUser then checking against their status. Example as follows.
Global
Triggers: gj_onAfterUpdateUser,gj_onAfterCreateUser
Type: Usergroup
User: Automatic
Access: Everybody
Conditions
Condition 1
Field: Custom > Usergroups
User: Action User
Operator: Does Not Have
Usergroups: SELECT_USERGROUP_HERE
Condition 2
Field: Custom > Value
Custom Value: [var1_status]
Operator: Equal To
Value: GROUP_STATUS_HERE
Action
Mode: Add Usergroups
Groups: SELECT_USERGROUP_HERE
Replace GROUP_STATUS_HERE with the status you want to check against. Refer to the list provided above. So for example set this to 4 to give the selected SELECT_USERGROUP_HERE usergroup to the user if they're a group owner.
Now to reverse this you'll want to do the following. Gets a bit trickier here as we need to use a Query condition to check against all their group status as we don't want to remove Owner for example if they stop being owner of 1 of 5 groups.
Global
Triggers: gj_onAfterUpdateUser,gj_onAfterDeleteUser
Type: Usergroup
User: Automatic
Access: Everybody
Conditions
Condition 1
Field: Custom > Usergroups
User: Action User
Operator: Has
Usergroups: SELECT_USERGROUP_HERE
Condition 2
Field: Custom > Query
Custom Query:
Code:
SELECT DISTINCT `status` FROM `#__groupjive_users` WHERE `user_id` = '[user_id]'
Operator: Does Not Contain
Value: GROUP_STATUS_HERE
Action
Mode: Remove Usergroups
Groups: SELECT_USERGROUP_HERE
Now this should remove SELECT_USERGROUP_HERE if the user is no longer of status GROUP_STATUS_HERE in any groups.