Answers.Body: <p>You can use rules module where you set condition upon node submit to perform to add user to CiviCRM group. </p>
  
  <p>Module: Rules/ CiviRules </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-09T12:33:51.427Z
Answers.Text: Hi Pradeep. I have tried that but I can't seem to get the rules to work. It does not fetch the right details to add in the data selector. Any ideas?
Answers.UserDisplayName: Sohal Khatwani
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-09T12:50:50.033Z
Answers.Text: What details are you looking for??
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-09T16:05:25.483Z
Answers.Text: Also - you may need to have `civicrm_entity` installed as well.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-09T23:28:18.610Z
Answers.Text: Thanks Guys. @PradeepNayak - I am having trouble with the data selector to add the Contact to the CiviCRM Group. I will edit the question and link an image there. I have installed the civicrm_entity module.
Answers.UserDisplayName: Sohal Khatwani
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-11T11:44:02.377Z
Answers.Text: For anyone looking for the answer I have added this below.
Answers.UserDisplayName: Sohal Khatwani
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-09T11:47:40.417Z
Answers.LastActivityDate: 2018-05-09T11:47:40.417Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>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.</p>
  
  <pre><code>{ "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" } }
          }
        }
      ]
    }</code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-11T11:43:33.873Z
Answers.LastActivityDate: 2018-09-11T11:43:33.873Z
Answers.UserDisplayName: Sohal Khatwani
Body: <p>I am trying to add the current user logged in to the Drupal 7 site to a CiviCRM group when they add content. For example we have a business directory and the signed in user can submit their listing. I want the user who submits the listing to be added a CiviCRM group called business directory which can then be used to email them in the future. </p>
  
  <p>I tried using the contact reference field but this allows me to select the user. We want it to automatically select the signed in user. </p>
  
  <p>Further, I am trying to get the rule to add the user to the group. </p>
  
  <p>Has anyone achieved this with Drupal 7 &amp; CiviCRM 4.7X. </p>
  
  <p><a href="https://i.sstatic.net/g7AaY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/g7AaY.png" alt=""></a></p>
  
  <p>Thanks.</p>
  
Tags: <drupal><groups><drupal-rules>
Title: Link Drupal Node Content to a CiviCRM user and add user to a group?
ThreadText: # Link Drupal Node Content to a CiviCRM user and add user to a group?
  
  (Asked by: username_0 on 2018-05-09)
  
  I am trying to add the current user logged in to the Drupal 7 site to a CiviCRM group when they add content. For example we have a business directory and the signed in user can submit their listing. I want the user who submits the listing to be added a CiviCRM group called business directory which can then be used to email them in the future.
  
  I tried using the contact reference field but this allows me to select the user. We want it to automatically select the signed in user.
  
  Further, I am trying to get the rule to add the user to the group.
  
  Has anyone achieved this with Drupal 7 & CiviCRM 4.7X.
  
  [![](https://i.sstatic.net/g7AaY.png)](https://i.sstatic.net/g7AaY.png)
  
  Thanks.
  
  **Tags:** drupal, groups, drupal-rules
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-05-09. Score: 2
  
  You can use rules module where you set condition upon node submit to perform to add user to CiviCRM group.
  
  Module: Rules/ CiviRules
  
  > **Comments:**
  > **username_0**: Hi username_1. I have tried that but I can't seem to get the rules to work. It does not fetch the right details to add in the data selector. Any ideas?  
  > **username_1**: What details are you looking for??  
  > **username_2**: Also - you may need to have `civicrm_entity` installed as well.  
  > **username_0**: Thanks Guys. @username_1 - I am having trouble with the data selector to add the Contact to the CiviCRM Group. I will edit the question and link an image there. I have installed the civicrm_entity module.  
  > **username_0**: For anyone looking for the answer I have added this below.  
  
  ---
  
  ### Answer by username_0 on 2018-09-11. Score: 1
  
  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" } }
          }
        }
      ]
    }
  ```
  
  
  ---
  
  