A site I'm developing used WP Post Favorites to store post IDs in the usermeta table. I'm now trying to port this data over to a new site (the users and usermeta tables have been migrated over), but using a different plugin (Favorites). The new site has the same content but the post IDs have changed for various reasons that we can't control.

What I'm attempting to do is write a script that:

Replaces the old post IDs with the new post IDs from the new site.in the 'wpfp_favorites' usermeta key for each user. I have the corresponding old and new post IDs in a csv file.

Change the usermeta data from the format of the old plugin ('wpfp_favorites' meta key: a:3:{i:0;s:4:"4615";i:1;s:4:"2747";i:2;s:4:"9635";} to the format of the new plugin ('simplefavorites' meta key:
a:1:{i:0;a:3:{s:7:"site_id";i:1;s:5:"posts";a:1:{i:0;i:9075;}s:6:"groups";a:1:{i:0;a:4{s:8:"group_id";i:1;s:7:"site_id";i:1;s:10:"group_name";s:12:"Default List";s:5:"posts";a:1:{i:0;i:9075;}}}}}

Notes:

All of the post IDs are 4 digits long so the serialization shouldn't be too big a deal

The way I see it we would probably need to run a one-time SQL query, or maybe a WP action that only runs once for each user on their next login

Technically replacing all post IDs on the new site to match the old site would work, but this seems like it would be more complicated given the postmeta table, etc

Keep in mind this is a Q&A site not a discussion forum, you need to be able to mark an answer as the canonical absolute correct answer for all people who have the same question. Guidance doesn't really fit into that =/
– Tom J Nowell♦Apr 28 '18 at 1:51