Quantcast
Channel: 'Create Linked Drupal User Account' problem - bug or user error? - CiviCRM Stack Exchange
Viewing all articles
Browse latest Browse all 2

'Create Linked Drupal User Account' problem - bug or user error?

$
0
0

I am trying to set up a rule to create a Drupal User when a Contact is created. The obvious approach is to fire on the event 'CiviCRM Contact has been created, check for the correct Contact subtype, and that a User does not already exist, and then use the action 'Create Linked Drupal User Account'.

This does not work on creating a Contact, giving an error message: Cannot create user, email: invalid!!

The Rules debug information in this case is:

0 ms Reacting on event CiviCRM Contact has been created.2.397 ms Evaluating conditions of rule Test Rule. [edit]2.473 ms The condition civicrm_entity_contact_is_subtype evaluated to TRUE [edit]6.878 ms The condition civicrm_entity_user_exists evaluated to FALSE [edit]6.88 ms AND evaluated to TRUE. Rule Test Rule fires [edit] 0 ms Rule Test Rule fires. 0.041 ms Evaluating the action civicrm_entity_action_create_user. [edit] 232.936 ms Rule Test Rule has fired.239.83 ms Finished reacting on event CiviCRM Contact has been created.

The only messages in the Drupal log are copies of the error message and the Rules debug log.

BUT if one then updates the same Contact, using the same webform and the same Rule with the Contact Updated event added, it works and the User is created. (This says a timing or sequencing problem to me, or a difference I haven't spotted in the syntax required in the two cases.)

What is going on?

The Rule export is:

{ "rules_test_rule" : {"LABEL" : "Test Rule","PLUGIN" : "reaction rule","OWNER" : "rules","REQUIRES" : [ "civicrm_entity", "civicrm" ],"ON" : { "civicrm_contact_create" : [], "civicrm_contact_edit" : [] },"IF" : [ { "civicrm_entity_contact_is_subtype" : { "civicrm_contact" : [ "civicrm_contact" ],"contact_subtype" : "xxxx_Member" } }, { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm_contact" ] } } ],"DO" : [ { "civicrm_entity_action_create_user" : {"USING" : {"civicrm_contact" : [ "civicrm-contact" ],"is_active" : "1","notify" : "0","signin" : "1","username_format" : "firstlast" },"PROVIDE" : { "civicrm_user" : { "username" : "Created Drupal User" } } } } ] }}

Configuration includes:CiviCRM 5.3.2 (including CiviCRM Rules Integration);
Drupal 7.59;
CiviCRM Entity 7.x-2.1;
Rules 7.x-2.11;
and dependencies.

(I have looked at the answers to various related questions and cannot get any joy. Those that are using the same approach don't seem be any help in getting mine working. Some suggest setting a Tag and then firing a rule off the Tag creation event - the CiviCRM Tag entity does not show up in the event selection list on my system, so I can't use that.

I have done something similar to the Tag suggestion using the Relationship created event, which does work (as far as I have tested it so far) but it's clearly a kludge (apologies) workaround. Should not the straightforward approach work?)

Thanks in advance,Tony


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images