Hi!

I have the following scenario:

I have a custom field in my user profile (a drop down selection) so that, when a new member joins up, they indicate whether they are a member of either Group A or Group B.

How do I program a triggered rule so that it takes this CCK value and adds a corresponding user role?

Ultimately, I then want to use role membership so that, when using Ubercart, they are presented with a custom price, depending if they are Group A or Group B. I can do this using the Price Per Role module. There will be other basic node privileges based on their membership.

I can see that the Rule Event needs to be when the "user account has been created" but when I add a Rule Condition I can't select the CCK fields. Instead, I am advised:

"The following conditions aren't available in this context because they require arguments that don't exist in your rule. If you want to use any of these conditions, you must first add some action that adds variables of this kind in a previous rule, or have an event that passes the required variables."

I can't see how adding an action is relevant here?

Is there another way around this?

Is it a case of coding an IF statement in some PHP code somewhere (where?!), i.e. IF CCK_Field='Group A' THEN role='Group A'?

Oh, what it would be to be clever!

Many thanks in advance of any advice offered :o)

Ali

Comments

crabsoul’s picture

see this thread: http://drupal.org/node/632140
i think you can use "rules" module to fill your requirement.

Hope it will solve your problem.

AliMartin’s picture

Hi Rashmi

Happy New Year :o)

Many thanks for your reply - it certainly makes most sense logically. However, thicko that I am, I'm having problems with the PHP code - would you be able to help me?

Quite simply, I have a custom select list on the user profile called "profile_industrysector" with three possible options:

- Auto retail dealer
- Car manufacturer
- Supplier company

When a new user registers I would like to add an additional role to their profile depending on their choice. So, if someone says they are an auto retail dealer, then I would like to grant them the role of "reg-dealer".

The latest code I've added for the triggered rule is as follows:

if ('profile_industrysector' == 'Auto retail dealer')
{
profile_save_profile($edit, $account, 'reg-dealer');
}

But it ain't working! Any advice?

Best wishes,

Ali

tryitonce’s picture

You should also look at Tutorial 2 - there is an explanation of how to create arguments - http://drupal.org/node/517674.

You just need to play a bit with it. I am also pretty new to this - but this module seems to be quite forgiving to those experimenting - so far.

good luck

WorldFallz’s picture

Another option might be to use http://drupal.org/project/autoassignrole module.