Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Patch attached with rules action "crm_core_user_sync_contact":
* takes a user argument (required) and contact (optional)
* creates a new CRM Contact if it was not supplied
* creates the relation object to sync the two
It's working ok for me on a few dev sites, but haven't tested yet in production.
Related to #2206859: Creating a user from CRM Contact?
Comment | File | Size | Author |
---|---|---|---|
#4 | crm_core_user_sync-sync_or_create_contact-2256515-3.patch | 2.91 KB | AaronBauman |
Comments
Comment #1
AaronBaumanComment #2
RoSk0Need a dot at the end.
If contact already exists we should load relation and return both.
We should save contact after this.
Patch needs to be restructured and created following Drupal coding standards.
Comment #3
AaronBaumanPatch re-rolled with one change.
Dot added
Yes, I guess we need to deal with an existing contact ... somehow.
If a contact is given as an argument to this action, we cannot just ignore it.
There's no "merge entity" mechanism that I know about - any ideas?
I disagree here. In general when rules returns a new or existing entity, it's up to the rule builder to add the "entity_save" action. If the rule builder has more work to do on the new entity, it's much more efficient to wait until the work is done before saving. This is how node and user actions work, as well as other entity types, so that's how I've modeled this action.
Comment #4
AaronBaumancorrect patch, wrong name.
renamed and re-uploaded
Comment #5
RoSk0Still brakes coding standards.
Please refer to Coding standards.
I would recommend using Helper Modules.
Comment #6
grahlClosing outdated issue, please reopen if still relevant.