2
votes

What I am trying to achieve is: 1) I have a Profile2 field in the user registration form called: "Firm Type" 2) I need to assign the new user a Role based on the selection in this field.

I have tried the following:

Event: After saving a new account Condition: Data Comparison: account:profile-additional-registration-info:field-profile-firm-type Action: Add a user role

The above Rule works fine when I remove the condition. As soon as I add the condition the rule does not work. Digging into this I found out that Rule gets executed after Account is saved and before Profile2 is saved.

I looked online to find these 2 links helpful: https://www.drupal.org/node/1872384 https://www.drupal.org/node/2009878

1 suggestion was: Event: After saving a new profile Condition: Data Comparison: Profile2:field Action: Heres where the problem is -- I cannot get to the account level because its on a profile event.

Could you please help me figure this out. Any help would be really appreaciated! Thanks!

1
Never mind. I just figured it out. Incase if this helps anyone, here are the steps: Event: After adding a new profile After updating an existing profile Condition: Negate User Has Roles: Check all roles other than a Public Role <This is will not update the role if user is already in the system with another role and updates his profile> Data Comparison: profile2:field Action: Set a Data Value: site:current-user:roles Thanks!user3570925

1 Answers

0
votes

Here are the steps:

  • Rules Event: After adding a new profile After updating an existing profile

  • Rules Condition: Negate User Has Roles: Check all roles other than a Public Role Data Comparison: profile2:field

  • Rules Action: Set a Data Value: site:current-user:roles