On a node update (You can change it to node create) it captures the email address from the node i.e. directory and creates a new Drupal user and CiviCRM contact and assigns that contact to the group.
{ "rules_add_new_user_to_civicrm_group_working" : {
"LABEL" : "Add New User to CiviCRM Group - Working with New User",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"REQUIRES" : [ "rules", "civicrm", "civicrm_entity" ],
"ON" : { "node_update--directory" : { "bundle" : "directory" } },
"DO" : [
{ "entity_create" : {
"USING" : {
"type" : "user",
"param_name" : "[node:title]",
"param_mail" : "[node:field-directory-email]"
},
"PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
}
},
{ "entity_save" : { "data" : [ "entity-created" ], "immediate" : "1" } },
{ "civicrm_entity_action_load_create_contact" : {
"USING" : { "user" : [ "entity-created" ], "email" : [ "" ] },
"PROVIDE" : { "civicrm_contact" : { "civicrm_contact" : "Created or Loaded CiviCRM Contact" } }
}
},
{ "civicrm_entity_query" : {
"USING" : {
"type" : "civicrm_contact",
"property" : "id",
"value" : [ "civicrm-contact:id" ]
},
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched CiviCRM entity list" } }
}
},
{ "civicrm_entity_rules_action_assign_contact_to_group" : {
"contact" : [ "entity-fetched:0:contact-id-contact" ],
"group_id" : { "value" : { "2" : "2" } }
}
}
]
}