1

Here's what I have done so far (in Drupal 7):

  1. Created a webform quiz that only validates if all answers are correct
  2. Created a role called "Mid-program quiz: Passed" that has permissions to view a particular page
  3. Created a rule that says upon submission of the quiz, the submitting user should be granted the "Mid-program quiz: Passed" role.

But it's not working. The quiz is being submitted correctly but the role is not being assigned.

Here are the details of the rule that's failing to execute:


Event

Event: After a webform submission has been added

Conditions: Webform has name

Parameter: The form id of the submitted form: [form_id], Webforms: Mid-program quiz

Elements

(Here I wasn't sure whether to use [user], i.e. the user submitting the webform, or [site:current-user], i.e. the currently logged-in user. So I did both.)

Add user role

Parameter: User: [user], Roles: Mid-program quiz: Passed

Add user role

Parameter: User: [site:current-user], Roles: Mid-program quiz: Passed


Can someone see where the problem is in this rule?

Thanks!

  • Upon further debugging, it also looks like the problem isn't with Event or the Elements. It appears to be in the Conditions. I also tried Webform has name Parameter: The form id of the submitted form: [node:title], Webforms: Mid-program quiz ... but that doesn't work either. – beth May 8 '12 at 14:31
  • You said it looks like the problem is in the conditions... so if you remove the condition, the role evaluates correctly? – Patrick Kenny May 8 '12 at 15:08
  • Yes. Without the condition the role is added to the user upon submission of any webform. I actually figured out the problem and typed up an answer but I have to wait 8 hours from the original question before I can post it. – beth May 8 '12 at 17:40
0

Adding Roles with Rules upon Webform submission not working — Why?

Okay, it looks like I figured it out:


  • Event: After a webform has been submitted
  • Condition: Webform has name
    • Parameters:
      • The form id of the submitted form: [form_id]
      • Webforms: Mid-program quiz
  • Action: Add user role
    • Parameters:
      • User: [user]
      • Roles: Mid-program quiz: Passed

So the confusing things to watch out for are:

  • "After a webform has been submitted" is the one to choose, over "After a webform submission has been added."
  • Webform Has Name has first parameter as ID and second as the webform (as selected from a list of webforms). It makes it seem like you're saying nid has to be equal to a title, which doesn't seem like it would work, but that's apparently not what's happening.
  • Add user role takes simply Parameter:user, rather than site:user or any other attribute of user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.