An alternative method to role management in #drupal
- Create a rule to trigger off of the event: User approved to group by admin. The department groups used membership moderation so this event made sense.
- Add the condition: Execute custom PHP code. We use this condition to check and see if the user is joining a particular department. In the text box labeled PHP Code I entered the following: return (module_exists('og') && og_is_group_member(INSERT_GROUP_NODE_ID_HERE, FALSE, $acount->uid)); This code first checks to make sure the organic groups module exists. If we forget this check and the module is removed from the system for some reason, bad things happen. The second part of the code uses a function provided by the group module to check if a user (based on user ID) is a member of a group (based on node ID). You'll notice where we need to insert the group node IDs we wrote down from the earlier step.
- Add the action: Modify user roles. For the arguments configuration of this action we want to make sure we select User that subscribed to the group and not the active user. Select the department role we want to add and save the rule.
- Create a rule to trigger off of the event: User unsubscribes from group. I tested and verified that this event is triggered when a user manually leaves a group or if the group admin removes them.
- Add the condition: Execute custom PHP code and enter the following into the PHP code section:return (module_exists('og') && $group->nid == INSERT_GROUP_NODE_ID_HERE); This code first checks to make sure the organic groups module exists. The second part verifies that the group this code is triggering off of is the group we want. Remember we're removing one role for each rule.
- Add the action: Remove user role. Select the role to remove and also don't forget to set the argument configuration to User that subscribed to the group. Save the rule.
Do you have an alternative based on rules to reach a configuration like described here: http://drupal.org/node/711246 and here: http://drupal.org/node/742676#comment-2855062 ?
Best results I've reached is using OG + OGUR + WORKFLOW, but actually I have serious problem due to OGUR lack integration with Views (see: http://drupal.org/node/737292 ).
So I'm really interested in look for alternatives. Can you help me? A tutorial like the others you wrote would be very appreciated.
Thank you very much
MXT
I love solving problems like this so hopefully we can get it to work. :-)
I've been learning, toying with, and building Drupal websites for several years now. Throughout this time I've had to rely on the Drupal community to learn the ins and outs of this framework. It's about time I start giving back by blogging what I've learned in the hope that the next new Drupal user has an easier road ahead of them.

Subscribe via RSS