Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CiviCRM Profile Sync will remove CiviCRM Contact First Name and Last Name if WordPress User fields are not set #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agileware-justin
Copy link

CiviCRM Profile Sync will remove CiviCRM Contact First Name and Last Name if WordPress User fields are not set.

Agileware Ref: CIVIWPSYNC-1

…ame and Last Name if WordPress User fields are not set
@christianwach
Copy link
Owner

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!

@christianwach
Copy link
Owner

@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.

@agileware-justin
Copy link
Author

@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.

@christianwach
Copy link
Owner

@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.

@tresero
Copy link

tresero commented Sep 11, 2023

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?

@christianwach
Copy link
Owner

christianwach commented Nov 23, 2023

@tresero It's not as simple as having a flag though. Consider this scenario:

  • User wants to anonymise their public profile so deletes their First Name & Last Name in WordPress
  • CiviCRM sync does not delete the corresponding fields
  • Contact record is updated for some reason
  • Contact First Name & Last Name gets synced back to WordPress, de-anonymising the User

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.

@christianwach
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants