CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • webform + rules + entities to create drupal user for new contact
Pages: [1]

Author Topic: webform + rules + entities to create drupal user for new contact  (Read 4135 times)

naomisl

  • I post occasionally
  • **
  • Posts: 51
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: Drupal 7.32
webform + rules + entities to create drupal user for new contact
May 08, 2014, 05:42:27 pm
i keep getting close and then moving further from the target. It's a fun dance, but it's getting frustrating! Anyone have ideas? Ok, here goes. I have the following modules:
 - Webform 4.0-rc3
 - Webform CiviCRM Integration 4.6
 - Rules 2.7
 - Webform Rules 1.6
 - Civicrm Entities 1.0

I currently have a webform that creates a pair of CiviCRM contact's with relationships to each other. I'd like the primary contact (the one filling out the form, and "contact 1" from the civicrm side) to be get a linked Drupal user account, and be sent an email with a link to set up a password. So I set up a rule, that goes like so:

Event: CiviCRM Contact has been created
Conditions: none
Actions: Create linked Drupal user account
              Parameter: CiviCRM Contact: [civicrm_contact], Activate Account: true, Send account notification email: true, Instant signin: true
              Provides variables: Created Drupal User (civicrm_user)

This rule, when tested, somehow creates a drupal user only for the second contact (contact 2 in the civicrm tab of webform). It also does not save an email address for that contact in the drupal side, and does not send an account notification email, likely because drupal doesn't have the account email somehow.

So as to single out the contact I want, I then tried creating a membership for contact 1, with a dummy membership type that is free and doesn't matter at all in other contexts. The second contact I did not give a membership to. The rule went as follows:

Event: CiviCRM Membership has been created
conditions: none
Actions: Create Linked Drupal User Account
            Parameter: CiviCRM Contact: [civicrm-membership:contact-id-contact], Activate Account: true, Send account notification email: true, Instant signin: true
            Provides variables: Created Drupal User (civicrm_user)

Even though the contacts got created alright and contact 1 did get a membership, this rule didn't fire at all. No user was created. However, when I tried using the exact same form  and rule again, this time only filling in the first user's data, it did fire as wanted, with the account email and everything. Arg!

Does anyone know what's going on, and how to get to my goal of creating a linked drupal user for contact 1 from a webform? I feel like I'm almost there, except not at all.




petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: webform + rules + entities to create drupal user for new contact
May 08, 2014, 05:49:46 pm
i thought i read some progress had been made on getting a Drupal User created from a webform - but can't go digging for that now.

I guess you took a look through how we did this here

https://civicrm.org/blogs/petednz/creating-drupal-users-made-easy-single-or-multiple-contacts-civi-imports-and-webforms
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: webform + rules + entities to create drupal user for new contact
May 08, 2014, 05:57:22 pm
for my own benefit i also found this old thread in drupal which might suggest another approach - https://drupal.org/node/1851378
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

naomisl

  • I post occasionally
  • **
  • Posts: 51
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: Drupal 7.32
Re: webform + rules + entities to create drupal user for new contact
May 12, 2014, 05:47:23 pm
Thank you! The rule that you linked to (https://civicrm.org/blogs/petednz/creating-drupal-users-made-easy-single-or-multiple-contacts-civi-imports-and-webforms) is working, mostly.

I'm still working out the kinks, so far it does what I want but throws an error code at the user. Still, it's very close. Thanks for setting me on the right track!

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: webform + rules + entities to create drupal user for new contact
May 12, 2014, 05:52:15 pm
Cool - pls update here any tweaks that might be required and i will aim to update it.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

naomisl

  • I post occasionally
  • **
  • Posts: 51
  • Karma: 0
  • CiviCRM version: 4.5.3
  • CMS version: Drupal 7.32
Re: webform + rules + entities to create drupal user for new contact
May 12, 2014, 06:23:01 pm
Got it! Ok, I used the custom rule labeled "updated Create User via Tag Rule - standard." In order to get it to load without installing the Domain & Domain Rules modules, I had to delete the requirement of those modules, like so:

    "REQUIRES" : [ "civicrm", "rules", "domain_rules" ],

With that change, it worked perfectly (after setting the tags as described) except that it was throwing the following error code at the user upon submission:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'domain_rules_action_set_user_domain' not found or invalid function name in FacesExtendable->__call() (line 123 of/home/makom/www/www/sites/all/modules/rules/includes/faces.inc).

To get rid of this, I went to the rule and deleted the "Set domain to a user" action. Now the error code is gone.

The only thing not working perfectly at this point is the option to have an instant sign-in for the newly created contacts. For some reason if this option is turned on, upon submission the new user is logged in and treated to a page that says "access denied." When it is turned off, the user is not signed in and sees the webform confirmation message instead. I've decided to leave it at that, but if someone else really wants instant sign-in, that would be something to work on.

Hope this helps someone, and thanks again for the assist! 

YossiCrm

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: webform + rules + entities to create drupal user for new contact
January 06, 2015, 10:36:10 pm
For some reason when I turned off instant Sign-in, the rule would not create the Drupal user nor send out the email.
I kept instant sign in on and worked around the "access denied" page by adding an an action called page redirect which allows you to enter a url to which new users will be redirected.

Cheers!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • webform + rules + entities to create drupal user for new contact

This forum was archived on 2017-11-26.