Hi. I have the following situation.
I have users with Content Profile. Besides I have a Content Type called Customer. By node_reference on the profile, each user is assigned a customer.
Besides I have Organic Groups. Each Customer, via node_reference, has a Group assigned.
So, my needs are:
- When the Group Admin adds a member to a group, the Customer assigned to the group must be the same as the Customer assigned to the user in his content profile.

Any help??

Comments

itangalo’s picture

I don't know the anatomy of Organic Groups, but here's a sketch for a solution:

1. Activate Rules Forms Support (included in the Rules project)
2. Activate form events for the Add user form in Organic Groups.
3. Set conditions checking all the stuff you want to check (details will follow)
4. If the customer assigned to the group isn't the same as the user in the acting user's content profile, set a validation error (and display an explanation in a message box)

The tricky part here will of course be step 3.
From what I know from OG, you won't get a neat list of users that were added in the form -- all users are listed in a textarea. On top of this, you won't have any user profile loaded to compare to -- any loading of user profile is done in actions made *after* the conditions are checked.

Considering all this, you'll probably have to write custom PHP code for validation, (a) turning the string of users into a neat array, (b) loading the user profile, and (c) checking if there is any match between customers in profile and the array of users. Since I don't know OG very well I can't really help you on this one, but you'll have use for the PHP filter module (included in core).

A different approach would be to find an action that adds members to a group in OG, and let group administrators use VBO or a CCK Button Field (http://drupal.org/project/cck_button) to add selected users with a single click. Then you could override the Add users page all together.

Good luck!
//Johan Falk, NodeOne, Sweden
PS: I'm not maintaining the Rules module, just helping with support questions. You are welcome to ask more questions at http://groups.drupal.org/rules

mitchell’s picture

Component: Rules Engine » Rules Core
Status: Active » Closed (fixed)