Open agileware-justin opened 2 years ago
Thanks for this @agileware-justin - could you make the PR conform to WordPress coding standards as per the phpcs.xml
file? It's currently CiviCRM formatted. Cheers!
@agileware-justin Hmm, so it doesn't seem to be true that both "First Name" and "Last Name" are required by CiviCRM. I can see that you don't want to lose data in CiviCRM, but I don't think this is the way to go about that. You can use the cwps/contact/name/should_be_synced
filter to inspect the proposed update and reject those with less data than your install requires.
A full solution might involve an option on the Settings screen that allows a policy to be chosen, but I suspect these could get complicated. I think documentation with some example code might help.
@christianwach thanks for reviewing. This PR arose from a support request whereby a customer had added ~2,000 new WordPress user accounts to their site. Those user accounts only had the email address set.
When the profile sync process ran, the existing CiviCRM contacts matching those WordPress user accounts lost their first and last names.
Consequently, there was no longer any record of this information either in WordPress or CiviCRM. CiviCRM logging was not enabled.
CiviCRM database needed to be restored from backup, contacts exported and re-imported.
If anything, this PR was to highlight that this problem can occur.
@agileware-justin Yes, I fully understand the problem - I just can't see a way to accommodate the range of needs in this plugin. There may be cases where overwriting with empty values in either direction is the desired behaviour. There may be cases where it's not. That's why I suggested using the filter - sync policies are much easier to implement on a site-by-site basis than though a UI or "one size fits all" solution.
I'm open to suggestions on how to implement such policies via the UI, of course. And also happy to accept updates to the readme files to illustrate how to write policies in code. Sorry I can't be more helpful at this point.
I am having this exact problem. We have 25k+ civi contacts and are allowing them to update their own data. The only way to do this as far as I'm aware is for them to register. Even if I add the First Name and Last Name fields to the registration form, this plugin overwrites the name with email.
I know the cases can get crazy, but I think that first and last names are very important and an easy solution is have a flag that says don't overwrite first/last names?
@tresero It's not as simple as having a flag though. Consider this scenario:
I would love to find a general solution to this, but I really think that it's a per-site task using the filters I mentioned above.
Even if I add the First Name and Last Name fields to the registration form, this plugin overwrites the name with email.
@tresero Can you post steps to reproduce? I'd be interested to see this in action.
CiviCRM Profile Sync will remove CiviCRM Contact First Name and Last Name if WordPress User fields are not set.
Agileware Ref: CIVIWPSYNC-1