Answers.Body: <p><a href="https://github.com/eileenmcnaughton/civicrm_entity/blob/7.x-2.x/civicrm_entity.module#L3237" rel="nofollow noreferrer">https://github.com/eileenmcnaughton/civicrm_entity/blob/7.x-2.x/civicrm_entity.module#L3237</a></p>
  
  <p>remove the ampersand from the $contact parameter</p>
  
  <pre><code>function civicrm_entity_contact_has_location_element_email($contact, $location_type_id) {
  </code></pre>
  
  <p>This is a bug, can you make an issue in the CiviCRM Entity project issue queue? I need to trace back how this code got that way, and see if there's any other reasons why it is as it is now before I put it into the release</p>
  
  <p>But I can't think of any reason why it should</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-07T04:44:20.097Z
Answers.LastActivityDate: 2018-11-07T04:44:20.097Z
Answers.UserDisplayName: jackrabbithanna
Body: <p><em>The desired outcome was to create a drupal user record if and only if an email exists on the contact  - when a membership was created/updated.</em></p>
  
  <p>To do this I wanted to add the condition "CiviCRM Contact has Email".</p>
  
  <p>Testing this on multiple sites I've come to the conclusion that it doesn't appear to be working as advertised - it's not returning true when the associated contact has an email.</p>
  
  <p>I've tested using these two stripped down rules - (It's not working on civicrm contact is updated either) - pasted below.</p>
  
  <p>The only think I can think off that could be causing this is that the data selector is not correct? I tested this by outputting this using the debug action but perhaps it needs an ID not a "contact" or vice versa? I can't see any errors in the drupal log that would indicate this though. The rule is returning successfully - it's not generating any warnings.</p>
  
  <p>Membership update</p>
  
  <pre><code>{ "rules_test_2" : {
      "LABEL" : "Test 2",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "civicrm", "rules", "devel" ],
      "ON" : { "civicrm_membership_edit" : [] },
      "IF" : [
        { "civicrm_entity_contact_hasemail" : {
            "contact" : [ "civicrm-membership:contact-id-contact" ],
            "location" : "0"
          }
        }
      ],
      "DO" : [
        { "drupal_message" : { "message" : "Has email" } },
        { "devel_debug" : { "value" : [ "civicrm-membership:contact-id-contact" ] } }
      ]
    }
  }
  </code></pre>
  
  <p>Contact update</p>
  
  <pre><code>{ "rules_test" : {
      "LABEL" : "Test",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "civicrm", "rules" ],
      "ON" : { "civicrm_contact_edit" : [] },
      "IF" : [
        { "civicrm_entity_contact_hasemail" : { "contact" : [ "civicrm-contact" ], "location" : "0" } }
      ],
      "DO" : [ { "drupal_message" : { "message" : "Has emali" } } ]
    }
  }
  </code></pre>
  
Tags: <drupal><civicrm-entity><drupal-rules>
Title: Drupal Rules - Condition "Civicrm Contact has email" appears to not be working
ThreadText: # Drupal Rules - Condition "Civicrm Contact has email" appears to not be working
  
  (Asked by: username_0 on 2018-11-07)
  
  The desired outcome was to create a drupal user record if and only if an email exists on the contact  - when a membership was created/updated.
  To do this I wanted to add the condition "CiviCRM Contact has Email".
  Testing this on multiple sites I've come to the conclusion that it doesn't appear to be working as advertised - it's not returning true when the associated contact has an email.
  I've tested using these two stripped down rules - (It's not working on civicrm contact is updated either) - pasted below.
  The only think I can think off that could be causing this is that the data selector is not correct? I tested this by outputting this using the debug action but perhaps it needs an ID not a "contact" or vice versa? I can't see any errors in the drupal log that would indicate this though. The rule is returning successfully - it's not generating any warnings.
  Membership update
  { "rules_test_2" : {
      "LABEL" : "Test 2",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "civicrm", "rules", "devel" ],
      "ON" : { "civicrm_membership_edit" : [] },
      "IF" : [
        { "civicrm_entity_contact_hasemail" : {
            "contact" : [ "civicrm-membership:contact-id-contact" ],
            "location" : "0"
          }
        }
      ],
      "DO" : [
        { "drupal_message" : { "message" : "Has email" } },
        { "devel_debug" : { "value" : [ "civicrm-membership:contact-id-contact" ] } }
      ]
    }
  }
  
  Contact update
  { "rules_test" : {
      "LABEL" : "Test",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "civicrm", "rules" ],
      "ON" : { "civicrm_contact_edit" : [] },
      "IF" : [
        { "civicrm_entity_contact_hasemail" : { "contact" : [ "civicrm-contact" ], "location" : "0" } }
      ],
      "DO" : [ { "drupal_message" : { "message" : "Has emali" } } ]
    }
  }
  
  **Tags:** drupal, civicrm-entity, drupal-rules
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-07. Score: 2
  
  https://github.com/eileenmcnaughton/civicrm_entity/blob/7.x-2.x/civicrm_entity.module#L3237
  remove the ampersand from the $contact parameter
  function civicrm_entity_contact_has_location_element_email($contact, $location_type_id) {
  
  This is a bug, can you make an issue in the CiviCRM Entity project issue queue? I need to trace back how this code got that way, and see if there's any other reasons why it is as it is now before I put it into the release
  But I can't think of any reason why it should
  
  
  ---
  
  