I recently had a problem where I imported a whole bunch of users who previously had no Foreign Key, and in the import I included a Foreign Key.
The result was, over 1000 users whose previous PHPlist record had the email address changed to "Duplicate xxx@yyy.zzz" and who had a new record created with the new Foreign Key and the email address and other attribute other info from the import file.
(What I had hoped/assumed would happen is that when the PHPList detected there was no existing Foreign Key for that record it would go ahead & match by email instead. See my solution for that issue here.)
For a lot of the entries this situation was a bit annoying but fine. But many of my users had subscribed to various email lists beyond the one I subscribe them to via the import, had entered various attribute data I don't set via the import, had set an RSS Frequency (which I don't set via the import), etc.
Going to the "Manage Users/Reconcile Users" page I saw a function that looked helpful: Merge duplicate users.
However reading the documentation, the source code, & experimenting, I found that "Merge Duplicate Users" does three things--somewhat userful but both less and more than what I really needed:
* It moves all message/message sent info from the duplicate user to the main user
* It moves all bounce info from the duplicate user to the main user
* It deletes all list subscriptions for the duplicate users
What I needed to do:
* Move attribute data from the duplicate user to the main user (skipping this step, however, if the main user already had info for a particular attribute)
* Move all list subscriptions from the duplicate user to the main user
* Move the RSS Frequency from the duplicate user to the main user (skipping this step if the main user already had an RSS Frequency set)
Also the "delete list subscriptions for duplicate users" caused me a lot of headaches. The list subscription information was exactly the most valuable information that was lost when I imported the members with the new Foreign Key. When I ran "Merge duplicate users" it erased all those list subscriptions and I was lucky I had a very recent backup copy of the list subscription table to restore that data.
To take care of all of these problems, I re-tooled the "Merge duplicate users" function to
- move bounces
- move message info for users
- merge the list subscriptions
- merge attribute values (but only if that attribute is blank/NULL in the main entry)
- avoid deleting list subscriptions for the duplicate users
The necessary code for this mod to reconcileusers.php is in the following message.