Answers.Body: <p>With further testing I have established that was caused by a clash with another rule with the same event and weight. Changing the weight on the other rule has removed the error notice.</p>
  
  <p>The other rule (checking for an existing account for the user, and unblocking that rather than creating a new one) still isn't working, but that's another question!</p>
  
  <p>I'm not really clear why the order the rules run in should have made much difference or triggered this error, but happy to have it cleared up for now!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-26T15:11:39.210Z
Answers.LastActivityDate: 2019-04-26T15:11:39.210Z
Answers.UserDisplayName: somnolentsurfer
Answers.Body: <p>The message is a 'Notice' which can sometimes be ignored.  However, looking at the code causing the message the purpose of the function is to load a user entity based on the contact id but the contact id is not set which is fundamental to the purpose of that function.</p>
  
  <p>It would take a bit of debugging to track down where and why that is being called from your rule in a way that causes the contact_id not to be set - and ideally you would do that.  Alternatively providing it is does what you need in creating the Drupal user correctly you could choose to ignore it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-26T13:49:53.590Z
Answers.Text: I've removed the condition for no existing account, and the error has disappeared. I'm now concerned that the rule will attempt to create accounts when one already exists though. What's the correct way to safeguard against that? Or can I trust Rules/Drupal to do it automatically?
Answers.UserDisplayName: somnolentsurfer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-26T13:02:24.593Z
Answers.LastActivityDate: 2019-04-26T13:02:24.593Z
Answers.UserDisplayName: Aidan
Body: <p>Following the advice I received in <a href="https://civicrm.stackexchange.com/questions/28501/allow-only-existing-civicrm-contacts-to-create-own-drupal-account">Allow only existing CiviCRM contacts to create own Drupal account</a>, I'm trying to implement Drupal Rules to create an associated Drupal user whenever a CiviCRM contact is added to the 'Web Site Users' group.</p>
  
  <p>I'm running Drupal Core 7.66 and CiviCRM 5.12.3. Trying to get this working I've installed Entity API 1.9, Rules 2.12, and CiviCRM Entity 2.2.</p>
  
  <p>This is the rule I'm using:</p>
  
  <p><a href="https://i.sstatic.net/237d2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/237d2.png" alt="Screenshot of Drupal Rules showing Events: CiviCRM Contact has been updated, CiviCRM Contact has been created; Conditions: CiviCRM Contact is in Group Web Site Users, Not Drupal User Account exists for Contact; Actions: Create Linked Drupal Account"></a></p>
  
  <p>Creating a new contact in CiviCRM is correctly creating a new Drupal user, but I'm also getting this error, with no other visible consequences:</p>
  
  <blockquote>
    <p>Notice: Undefined property: CRM_Contact_DAO_Contact::$contact_id in
    civicrm_entity_contact_user_get() (line 3671 of
    /var/sites/c/civicrm.jesusshapedpeople.net/public_html/sites/all/modules/civicrm_entity/civicrm_entity.module).</p>
  </blockquote>
  
  <p>Should I be concerned? Am I doing something wrong? Is there a fix?</p>
  
Tags: <civicrm-entity><drupal-rules>
Title: Undefined property: CRM_Contact_DAO_Contact::$contact_id in civicrm_entity_contact_user_get()
ThreadText: # Undefined property: CRM_Contact_DAO_Contact::$contact_id in civicrm_entity_contact_user_get()
  
  (Asked by: username_0 on 2019-04-26)
  
  Following the advice I received in [Allow only existing CiviCRM contacts to create own Drupal account](https://civicrm.stackexchange.com/questions/28501/allow-only-existing-civicrm-contacts-to-create-own-drupal-account), I'm trying to implement Drupal Rules to create an associated Drupal user whenever a CiviCRM contact is added to the 'Web Site Users' group.
  
  I'm running Drupal Core 7.66 and CiviCRM 5.12.3. Trying to get this working I've installed Entity API 1.9, Rules 2.12, and CiviCRM Entity 2.2.
  
  This is the rule I'm using:
  
  [![Screenshot of Drupal Rules showing Events: CiviCRM Contact has been updated, CiviCRM Contact has been created; Conditions: CiviCRM Contact is in Group Web Site Users, Not Drupal User Account exists for Contact; Actions: Create Linked Drupal Account](https://i.sstatic.net/237d2.png)](https://i.sstatic.net/237d2.png)
  
  Creating a new contact in CiviCRM is correctly creating a new Drupal user, but I'm also getting this error, with no other visible consequences:
  
  > Notice: Undefined property: CRM\_Contact\_DAO\_Contact::$contact\_id in
  > civicrm\_entity\_contact\_user\_get() (line 3671 of
  > /var/sites/c/civicrm.jesusshapedpeople.net/public\_html/sites/all/modules/civicrm\_entity/civicrm\_entity.module).
  
  Should I be concerned? Am I doing something wrong? Is there a fix?
  
  **Tags:** civicrm-entity, drupal-rules
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-04-26. Score: 1 | Accepted answer
  
  With further testing I have established that was caused by a clash with another rule with the same event and weight. Changing the weight on the other rule has removed the error notice.
  
  The other rule (checking for an existing account for the user, and unblocking that rather than creating a new one) still isn't working, but that's another question!
  
  I'm not really clear why the order the rules run in should have made much difference or triggered this error, but happy to have it cleared up for now!
  
  
  ---
  
  ### Answer by username_1 on 2019-04-26. Score: 1
  
  The message is a 'Notice' which can sometimes be ignored. However, looking at the code causing the message the purpose of the function is to load a user entity based on the contact id but the contact id is not set which is fundamental to the purpose of that function.
  
  It would take a bit of debugging to track down where and why that is being called from your rule in a way that causes the contact\_id not to be set - and ideally you would do that. Alternatively providing it is does what you need in creating the Drupal user correctly you could choose to ignore it.
  
  > **Comments:**
  > **username_0**: I've removed the condition for no existing account, and the error has disappeared. I'm now concerned that the rule will attempt to create accounts when one already exists though. What's the correct way to safeguard against that? Or can I trust Rules/Drupal to do it automatically?  
  
  ---
  
  