Update:
For anyone having similar issues, I ended up figuring this out just after making my original post. As often seems to be the case when working with third-party plugins, the debugger can be misleading.
This was an issue of workflow actions not running synchronously, even when wrapped in a custom event, even though common wisdom suggests they should. The thing common wisdom neglects (and that I often forget) is that wrapping an action in a custom event, if this action relies on a third-party plugin, does not guarantee it will complete before subsequent steps run. The tricky bit is that this fact won’t be obvious when running in debug mode, since you’re slowing down execution.
The solution for me ended up being simple. I moved the “Read Local Storage” action out of the suspect workflow to my “page load” event to ensure the cookie’s value was actually readable before referencing it in the “sign the user up” step.
Hope this proves helpful to someone!
Original Post:
Hi there! Thanks so much for sharing all this. Very helpful. I’m hoping you might be able to help me troubleshoot an issue I’m running into when trying to implement something similar. It’s really got me stumped.
I’ve implemented a simple workflow using the “Local Storage & Cookies” plugin that drops a cookie containing the referring user’s unique id if the “ref” param is present and the current user is not logged in. On registration, I then check to see if this cookie is present and, if so, create a “referrer” record on the newly created user, pointing to the referring user.
Everything works as expected when dropping and updating the cookie. In debug mode, the registration flow seems to be working fine, as well. I can see the lookup of the referring user succeeding and the CRUD workflow to update the associated field on the new user looks to be working, as well.
The challenge is that, for some reason, this “referrer” record is not reflected in the database and, when I inspect my logs, I don’t see it there, either, even though I did see it being passed in debug mode. I’ve double checked my privacy settings and don’t see anything that could be causing issues there. I’m honestly totally stumped and wondering if you might see something I’m missing. Really appreciate any insights you can offer.