I have a rule where a user is sent an email, redirected to a specific page and given a site message if they select a certain value in a Profile2 field that is on registration. This is a one time signup for a rewards program so it is a field that gets hidden with field conditionals after it is created on registration. The rule works find if I sent conditions that are not Profile2 fields. However if I create a condition with a Profile2 field, the rule breaks and does not work.
Not sure if this is a rule issue or Profile2 issue. I tried editing the rule manually by swapping the key value for the real value, but no such luck...
Here is the rule I created:
{ "rules_sign_up_for_reserve_program" : {
"LABEL" : "Sign Up for Reserve Program",
"PLUGIN" : "reaction rule",
"TAGS" : [ "Reserve Program" ],
"REQUIRES" : [ "rules" ],
"ON" : [ "user_insert" ],
"IF" : [
{ "data_is" : {
"data" : [ "account:profile-reserve-membership:field-reserve-membership-sign-up" ],
"value" : "1"
}
}
],
"DO" : [
{ "redirect" : { "url" : "user\/[account:uid]\/addresses\/add" } },
{ "drupal_message" : { "message" : "WAIT! You are almost done. We just need you to fill out your address so that we can send you your Reserve Membership card." } },
{ "mail" : {
"to" : "email@mysite.com",
"subject" : "subject",
"message" : "message",
"from" : "email@mysite.com",
"language" : [ "" ]
}
},
{ "mail" : {
"to" : "[account:mail]",
"subject" : "subject",
"message" : "message",
"from" : "email@mysite.com",
"language" : [ "" ]
}
}
]
}
}
Comments
Comment #1
waltercat commentedconditionals with Profile2 works on other events, but not upon registration before or after saving a user.
Comment #2
fagoThe condition is working, bet during user registration the profile might not yet be connected to the user. I assume this is what happens here.
Comment #3
waltercat commentedSo is this a Profile2 issue then where it needs to connect to the user before the Rule executes? What I don't understand is that this is supposed to happen "after" the user is saved, so shouldn't the rule be executed after the complete user profile is built? I'm just a site builder, so I can't tell if this chain needs to be reorganized via Profile2 or if it is something Rules needs to account for. Happy to repost in Profile2 if that is the case.
Comment #4
smokris@waltercat: I just ran into this same problem — I was trying to create a Rule with Profile2 Conditions.
I changed the Rule's triggering event from "After saving a new user account" to "After saving a new profile" (and recreated my Conditions so they use the correct data selectors), and my Rule works now — the Profile2 entity is properly associated with the user by the point the "After saving a new profile" Rule fires.
Comment #5.0
(not verified) commentedRemoved personal site info.