2

On my site I am using two webforms from which a user can register to the site. This feature is enabled thanks to the webform_registration module. Of course these webforms can only be submitted by anonymous users.

What I want is, on the event of a submission, to populate the profile of the user who submitted the form with some of the data that were submitted. So I created a rule catching the event of a webform submission. Now how will I update the profile? Setting a data value on a user field does not work since the user who submitted the form was anonymous! He was created after. How can I do this? All I know about the user is just his username that can be pulled from the submission data. Any way to retrieve the user entity using his username and then writing the data to his profile?

1 Answer 1

3

You need to create and force-save both the User and the User's Profile before you set your data values. Your rules actions should look like the following:

  1. Create Entity - User
  2. Save Entity - User, Force Save
  3. Create Entity - Profile, choose profile type.
  4. Save Entity - Profile, Force Save
  5. Set Data Value(s)
1
  • Thanks for answering but I have abandoned that solution and returned to the original registration form. But to clarify my user was created by the WEBFORM_REGISTRATION module upon submission. So the problem was to retrieve the user entity first with rules and then populate his profile with the submission data. Your solution seems to be addressed for simple webforms, where upon submission YOU create the user with Rules. It is not a bad way of thinking. I am gonna go ahead and mark your answer as correct nevertheless. My original setup did not seem as viable solution. Yours seems better.
    – Perisdr
    Oct 15, 2012 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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