So, I'm working on a sample request feature which allows anonymous users to flag items and submit sample/inquiry requests. I'm debating converting the form to automatically register the user on submission, but I'm wondering if anyone had a way of saving the anonymous user's flags to the newly created user?
The flags module supports Rules integration and a flagging/unflagging event. I would look at that as a possible starting point for this feature. Rules has many different actions that should help you build out a workflow for such a scenario.
I am not aware of any module that already does this with flags. But you can take a look at Anonymous publishing. Its "Lazy Registration" mode will assign any node created by the anonymous user to a newly created user if that anonymous user later registers an account.
The method used is to require the anonymous user to submit and confirm an email address when creating a node. When somebody with that email register, the nodes tagged with that email address can be assigned to that newly created user.
It should not be difficult to use the same method to assign for flags/requests created by the anonymous user to a newly created user.
If you can allow for some errors, you can use something less intrusive than a confirmed email address to link the anonymous user to the newly created user, such as a persistent cookie (will fail when the cookie expires or the user moves to a different computer), or an IP-address (will fail if the user moves to a different computer, if two different users users use the same computer, or if a dynamic IP-address gets reassigned.)