Email created without location when syncing from CMS account
If you have a contact record in Civi without an email address, then create a CMS account (where unsupervised dedupe rule matches the CMS account to the Civi contact), then the email address is added to the contact record, but without a location. [This was discovered/tested with Drupal but looks like it would apply to all CMSes.]
The problem occurs in CRM_Core_BAO_UFMatch::updateContactEmail()
where the email is created and is easily fixed by adding eg $email->location_type_id = 1;
But digging further ...
-
Is there any need to use
CRM_Core_DAO_Email()
directly? Wouldn'tCRM_Core_BAO_Email::create()
be better? -
Do we have guidelines for when API is used within core? ie - is API Email.create ok/preferable?
-
Location is not a required field for email addresses, but has to be specified when creating addresses on contacts via the UI. Should it become a required field, possibly with a default value?
-
LocationType has a default value so that could be used as the default when creating email addresses