1

I have configured the rules same as in Setting up rule to link CiviCRM contact with Drupal 7 account it creates a drupal user if contact is created or updated in CiviCRM. But it doesn't get fired if the contact is created in CIviCRM through webform submission. It ends up with an error-"Cannot create user, email: invalid!!".Any help would be really appreciated.Thanks in advance!

2

You may need to add your rule here. The one by Christia is specifically about "updating a contact record in the CiviCRM" not about creating.

The only way we have made rules work for creation from webform is to add eg a Tag to the contact and then run the trigger off that. You need civicrm_entity.

This is cross-posted from the Drupal SE. Here is an example Rule you may be able to glean things from. It also auto logs in the contact.

{ "rules_self_create_user_account_and_login" : {
    "LABEL" : "Create User Account",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "civicrm", "rules" ],
    "ON" : { "civicrm_entity_tag_create" : [] },
    "IF" : [
      { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ] } },
      { "data_is" : {
          "data" : [ "civicrm-entity-tag:entity-table" ],
          "value" : "civicrm_contact"
        }
      },
      { "data_is" : { "data" : [ "civicrm-entity-tag:tag-id" ], "value" : "525" } }
    ],
    "DO" : [
      { "civicrm_entity_action_create_user" : {
          "USING" : {
            "civicrm_contact" : [ "civicrm-entity-tag:entity-id-contact" ],
            "is_active" : "1",
            "notify" : "1",
            "signin" : "1",
            "username_format" : "email"
          },
          "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
        }
      },
      { "redirect" : { "url" : "civicrm\/user?reset=1" } }
    ]
  }
}

You need to Add a new Tag - note the ID of that tag - change the exported Rule to the Tag you created for this purpose. Then also alter your webform so it adds that Tag automatically to the contact upon form submission

  • Thanks for the reply!! But I'm not getting which is the event I have to use from drupal rules. I'm not able to find anything related to creating a new tag as a event. It woyld be really great if you can post the event, condition and action. Thanks – preeti May 30 '18 at 9:40
  • do you have civicrm_entity installed? – petednz - fuzion May 30 '18 at 10:53
  • Yes I have installed Civicrm_entity – preeti May 30 '18 at 10:56
  • I tried to import the rule you have posted, but it fetches an error-Integrity check for the imported configuration failed. Error message: Data selector <em class="placeholder">civicrm-entity-tag:entity-id-contact</em> for parameter <em class="placeholder">civicrm_contact</em> is invalid.. – preeti May 30 '18 at 16:09
  • Thanks a lot!! it worked. But should the tag be added manually? – preeti May 30 '18 at 16:39
1

Here's an example Rule for Creating a user after a Webform CiviCRM submission; For the Event we're creating a helper Membership (we're really just Registering people to ride their bikes in an Event) - but the Membership gives us a nice Event to trigger on;

Using CiviMember to automatically create a Drupal 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.