Answers.Body: <p>Ok so the installation and use of the Webform Rules went a long way to contributing to resolve the issue in terms of restricting the triggering of the action of creating a user and also providing the webform fields to the rule process...</p>
  
  <p>And Aidan's info seemed like a possible solution and provided another way of doing things (but, I think, as pointed out by Aidan a lot has moved on since that information was published and so some of the options are no longer available in their former guise).</p>
  
  <p>... Then there was info from @Pierre.Vriens see the thread posted here:</p>
  
  <p><a href="https://drupal.stackexchange.com/questions/250929/webform-rules-create-a-drupal-user/250932#250932">Webform Rules - Create a Drupal User</a></p>
  
  <p>... where the recommendation was to try and use variables to hold the field values and then assign the variable as the value of the Drupal User Entity, which I did and it resolved the second part of the issue.</p>
  
  <p>Thanks to both @Aidan and @Pierre.Vriens for the help on this.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-24T15:37:42.623Z
Answers.LastActivityDate: 2017-11-24T15:37:42.623Z
Answers.UserDisplayName: Mo-ster
Answers.Body: <p>Most of what you need is here: <a href="https://civicrm.stackexchange.com/questions/11768/how-can-i-create-a-drupal-user-when-someone-submits-a-civicrm-webform">How can I create a Drupal user when someone submits a CiviCRM-Webform?</a> based on <a href="https://civicrm.org/blog/petednz/creating-drupal-users-made-easy-for-single-or-multiple-contacts-via-civi-imports-and" rel="nofollow noreferrer">@petednz-fuzion's blog post</a>.   It uses <a href="https://www.drupal.org/project/civicrm_entity" rel="nofollow noreferrer">civicrm_entity</a> which has seen a lot of activity since the previous question so there may be some changes but hopefully nothing that prevents you following it.</p>
  
  <p>For limiting action to a specific contact sub-type, add a new Condition using 'Data comparison' with a data selector of <code>civicrm-contact:contact-sub-type</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-24T13:54:11.727Z
Answers.Text: Hi Aidan... Thanks for the info and taking the time to look into the issue I am having... an interesting approach will see if it resolves my issue in totality... on a side note: since posting my question I was able to use create entity - then select User to create a Drupal user - however, it only seems to work when I statically assign the username and e-mail values not when I tell it too use the values provided in the form fields e.g. [data: {component}-value]
Answers.UserDisplayName: Mo-ster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-24T13:45:49.760Z
Answers.LastActivityDate: 2017-11-24T13:45:49.760Z
Answers.UserDisplayName: Aidan
Body: <p>I have a scenario - which I have no doubt that others will have come a crossed and some will have implemented.  The scenario is: to have a web form (created via the Webform module - which has CiviCRM fields integrated into it - via the Webform integration module) that has the CiviCRM fields such as:</p>
  
  <ul>
  <li>the first name,  </li>
  <li>the last name, </li>
  <li>the e-mail address, and </li>
  <li>the address
  (e.g. address line 1, address line 2, city, post code) etc</li>
  </ul>
  
  <p>and when the user (<strong>whom is not logged in - as they do not have a Drupal account</strong>)  selects submit</p>
  
  <ol>
  <li>The details entered are saved in CiviCRM, but equally </li>
  <li>A Drupal user is created for the user (<em>no doubt using the Rules module in Drupal</em>).</li>
  </ol>
  
  <p><strong>The issue is that</strong> </p>
  
  <ol>
  <li><p>I’d only want the rule fired if the web form was used, not if I create users via the CiviCRM admin interface (as I have sub-type contacts which wouldn’t need Drupal accounts assigned to them)</p></li>
  <li><p>When I go into Rules - I can find the triggering event, which i assume would be “CiviCRM Contact: Contact has been created” e.g. when a Contact is created the rule will begin to fire… </p></li>
  </ol>
  
  <p><a href="https://i.sstatic.net/qRQ62.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qRQ62.png" alt="enter image description here"></a></p>
  
  <p><br><br>
  <strong><em>what I’m not sure about is:</em></strong> </p>
  
  <p>2a. how to configure the condition for the rule to say “<strong>only do the action</strong> if the contact is of sub-type x” or if triggered by webform x</p>
  
  <p>2b. how to <strong>configure the action portion</strong> of the rule to create a new Drupal user</p>
  
  <p>2)b)i. there is the “Create a new entity” option under the Entities section in the drop down for action to add, where i can choose “User” as the value …</p>
  
  <p><em>Image 2: The rules screen - where trigger specified in top section</em></p>
  
  <p><a href="https://i.sstatic.net/jCoIn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jCoIn.png" alt="enter image description here"></a></p>
  
  <p><em>Image 3: The options user the actions options</em></p>
  
  <p><a href="https://i.sstatic.net/0QDmp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0QDmp.png" alt="enter image description here"></a></p>
  
  <p><br>
   <strong>however</strong>, on the next screen - where it asks for the login name of the user, the replacement patterns do not provide me with a means of saying use the e-mail entered in the registration form as the User name for the account that I want created; <strong>nor</strong> does it allow me to specify that the system should pick up the e-mail entered in the web form as use that as the email address for the new account being used.</p>
  
  <ul>
  <li><strong>side note:</strong> I do realise at this point having written the above that the rule was written saying do x when event y is triggered - and without specifying that event y should be coming from webform a, which might explain why the action portion of the rule is not providing any replacement pattern for the username - e.g the rule is generic so would be fired if a contact record was created via a different form or the general CiviCRM admin panel.</li>
  </ul>
  
  <p>So… anyone got any ideas on how to achieve what I’m trying to do above?  I assume I can do the above without having to get involved with writing bespoke modules or using hooks etc.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-24T12:18:46.247Z
Comments.Text: Ok it looks like I can use the Webform Rules module to restrict the firing of an action to a Webform ... this might address aspect 2)a) in the question...
Comments.UserDisplayName: Mo-ster
Tags: <drupal><webform-civicrm><user-account><drupal-rules><contact-types>
Title: Creating Drupal Accounts when a sub-type CiviCRM Contact is created - created by a webform
ThreadText: # Creating Drupal Accounts when a sub-type CiviCRM Contact is created - created by a webform
  
  (Asked by: username_0 on 2017-11-24)
  
  I have a scenario - which I have no doubt that others will have come a crossed and some will have implemented. The scenario is: to have a web form (created via the Webform module - which has CiviCRM fields integrated into it - via the Webform integration module) that has the CiviCRM fields such as:
  
  * the first name,
  * the last name,
  * the e-mail address, and
  * the address
    (e.g. address line 1, address line 2, city, post code) etc
  
  and when the user (**whom is not logged in - as they do not have a Drupal account**) selects submit
  
  1. The details entered are saved in CiviCRM, but equally
  2. A Drupal user is created for the user (*no doubt using the Rules module in Drupal*).
  
  **The issue is that**
  
  1. I’d only want the rule fired if the web form was used, not if I create users via the CiviCRM admin interface (as I have sub-type contacts which wouldn’t need Drupal accounts assigned to them)
  2. When I go into Rules - I can find the triggering event, which i assume would be “CiviCRM Contact: Contact has been created” e.g. when a Contact is created the rule will begin to fire…
  
  [![enter image description here](https://i.sstatic.net/qRQ62.png)](https://i.sstatic.net/qRQ62.png)
  
  ***what I’m not sure about is:***
  
  2a. how to configure the condition for the rule to say “**only do the action** if the contact is of sub-type x” or if triggered by webform x
  
  2b. how to **configure the action portion** of the rule to create a new Drupal user
  
  2)b)i. there is the “Create a new entity” option under the Entities section in the drop down for action to add, where i can choose “User” as the value …
  
  *Image 2: The rules screen - where trigger specified in top section*
  
  [![enter image description here](https://i.sstatic.net/jCoIn.png)](https://i.sstatic.net/jCoIn.png)
  
  *Image 3: The options user the actions options*
  
  [![enter image description here](https://i.sstatic.net/0QDmp.png)](https://i.sstatic.net/0QDmp.png)
  
  **however**, on the next screen - where it asks for the login name of the user, the replacement patterns do not provide me with a means of saying use the e-mail entered in the registration form as the User name for the account that I want created; **nor** does it allow me to specify that the system should pick up the e-mail entered in the web form as use that as the email address for the new account being used.
  
  * **side note:** I do realise at this point having written the above that the rule was written saying do x when event y is triggered - and without specifying that event y should be coming from webform a, which might explain why the action portion of the rule is not providing any replacement pattern for the username - e.g the rule is generic so would be fired if a contact record was created via a different form or the general CiviCRM admin panel.
  
  So… anyone got any ideas on how to achieve what I’m trying to do above? I assume I can do the above without having to get involved with writing bespoke modules or using hooks etc.
  
  **Tags:** drupal, webform-civicrm, user-account, drupal-rules, contact-types
  
  > **Comments:**
  > **username_0**: Ok it looks like I can use the Webform Rules module to restrict the firing of an action to a Webform ... this might address aspect 2)a) in the question...  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-11-24. Score: 2
  
  Ok so the installation and use of the Webform Rules went a long way to contributing to resolve the issue in terms of restricting the triggering of the action of creating a user and also providing the webform fields to the rule process...
  
  And username_1's info seemed like a possible solution and provided another way of doing things (but, I think, as pointed out by username_1 a lot has moved on since that information was published and so some of the options are no longer available in their former guise).
  
  ... Then there was info from @Pierre.Vriens see the thread posted here:
  
  [Webform Rules - Create a Drupal User](https://drupal.stackexchange.com/questions/250929/webform-rules-create-a-drupal-user/250932#250932)
  
  ... where the recommendation was to try and use variables to hold the field values and then assign the variable as the value of the Drupal User Entity, which I did and it resolved the second part of the issue.
  
  Thanks to both @username_1 and @Pierre.Vriens for the help on this.
  
  
  ---
  
  ### Answer by username_1 on 2017-11-24. Score: 2
  
  Most of what you need is here: [How can I create a Drupal user when someone submits a CiviCRM-Webform?](https://civicrm.stackexchange.com/questions/11768/how-can-i-create-a-drupal-user-when-someone-submits-a-civicrm-webform) based on [@petednz-fuzion's blog post](https://civicrm.org/blog/petednz/creating-drupal-users-made-easy-for-single-or-multiple-contacts-via-civi-imports-and). It uses [civicrm\_entity](https://www.drupal.org/project/civicrm_entity) which has seen a lot of activity since the previous question so there may be some changes but hopefully nothing that prevents you following it.
  
  For limiting action to a specific contact sub-type, add a new Condition using 'Data comparison' with a data selector of `civicrm-contact:contact-sub-type`
  
  > **Comments:**
  > **username_0**: Hi username_1... Thanks for the info and taking the time to look into the issue I am having... an interesting approach will see if it resolves my issue in totality... on a side note: since posting my question I was able to use create entity - then select User to create a Drupal user - however, it only seems to work when I statically assign the username and e-mail values not when I tell it too use the values provided in the form fields e.g. [data: {component}-value]  
  
  ---
  
  