I'm using your module which allows me to react to membership creations to create synced drupal users for contacts. This works great for individuals....but what happens for memberships on organization contacts? The organization has no email address... Can you see how creating a membership on an organization would differ from creating one on for an individual in context of using the rule action provided by your module to create a synced drupal user.

Really I don't want it to create a user for an organization...How can I stop that rule from triggering for organization contacts that get new memberships? Or does it already?
When I add a group membership to an organization I get this error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'name'

Trying to trace this down, recently upgraded to civi 4.3.3 so I'm not sure if its a civi issue or an issue with this module....
No errors in the drupal error log...
have also posted topic in the civi forum: http://forum.civicrm.org/index.php/topic,28854.new.html#new

Comments

eileenmcnaughton’s picture

If you turn on debugging you should get a backtrace - but it looks like it is trying to use a 'uf_name' - usually the email that is already in use.

I would expect you could add a data comparison against the contact type using rules chaining. ie. you add a data comparison condition & you can select the 'contact' & should then be able to select properties of the contact.

markusa’s picture

Status: Active » Closed (works as designed)

That was it, I:

1. Added a Fetch Entity by ID action, using the newly created memberships contact id
2. Added a conditional and and if with a data comaprison on the Fetched_contact's type, checking for Individual contact type
3. If it is only then do I invoke the action create Synced Drupal User

eileenmcnaughton’s picture

Cool - there isn't much documentation about this sort of stuff so if you get a chance to write some & post it somewhere please do!!

markusa’s picture

Ok, I'll add that I installed the rules_conditional module....http://drupal.org/project/rules_conditional

here's an export of the rule I'm using, I also added an action to automatically unblock the user....per my customers request...

{ "rules_create_drupal_user_when_new_member_joins" : {
"LABEL" : "Create Drupal User When new Member Joins",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "rules_conditional", "civicrm" ],
"ON" : [ "civicrm_membership_create" ],
"DO" : [
{ "entity_fetch" : {
"USING" : { "type" : "civicrm_contact", "id" : [ "civicrm-membership:contact-id" ] },
"PROVIDE" : { "entity_fetched" : { "contact_fetched" : "Fetched contact" } }
}
},
{ "CONDITIONAL" : [
{
"IF" : { "data_is" : { "data" : [ "contact-fetched:contact-type" ], "value" : "Individual" } },
"DO" : [
{ "civicrm_entity_action_create_user" : {
"USING" : {
"civicrm_contact" : [ "civicrm-membership:contact-id-contact" ],
"is_active" : 1,
"notify" : 1
},
"PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
}
},
{ "user_unblock" : { "account" : [ "civicrm-user" ] } }
]
}
]
}
]
}
}

eileenmcnaughton’s picture

Thanks - it's a pretty technical module so it's hard to show people what a real world use case might look like & how they might find it useful

sonicthoughts’s picture

I've used it to create a couple of rules:
1. Add a user to a group after registration of a certain event type
2. Trigger a scheduled job (using API) so scheduled reminder email fires immediately without waiting for cron)
3. Remove a user from a group when they fill out a webform.
I have on my "todo" list taking several usecases and documenting them.