Title probably isn’t as descriptive as it needs to be, but the issue I’m trying to solve is rather complex.
Here’s what I’m trying to do:
I’m building a site that requires the user to take a quiz before they register, while also providing the option to take the quiz and view the results without completing registration.
What I’ve done so far:
I’ve managed to get the ACF form tied into the (front end) registration form (using ACF woocommerce account fields plugin as the way to hook into that – this plugin has since stopped working with the latest version of Woocommerce, which means I now have to link these manually). This does successfully save form data to the User’s profile page after a successful registration.
That said, there’s a pretty big issue – if a new user abandons the registration process, their form data persists within the ACF form and stays that way until another user tries to take the quiz + register. The form does not clear itself after a user registers successfully either. If no user ever abandons the registration + quiz, then the data does not persist (but that’s impossible, there’s always going to be people who don’t complete the registration process).
What I’m trying to do now:
Now I’m trying to figure out if there’s a way to split the quiz from the registration process so anyone can take the quiz, save their answers to the current $_SESSION, and then if they decide to register, have that $_SESSION data pass the answers along to populate the appropriate ACF fields in their new profile. I figure if I can do this, it will get rid of some of the persistent data issues I described above while avoiding future compatibility issues when Woocommerce needs to update the form-login.php file.
TL;DR QUESTIONS:
- Is the persistent data issue a known bug with ACF 5+?
- Is there a better way of tying in a front-end ACF form to the user registration form that I’m unaware of?
- How do I pass ACF values to $_SESSION, and how do I take those $_SESSION values and pass them through the registration form submit so they populate the correct fields for the new user?
I can share code if it’s needed, but I’m really working with a pretty vanilla ACF front-end form. I don’t necessarily need pseudo/working code so much as I’m asking for input on what filters may need to be used + why because I can’t find much information on this type of scenario.
Anyway, thanks so much for reading through all of this! And thanks in advance to any and all input/comments/feedback. It’s all really appreciated. 😀