Stopping Same Form Being Updated Twice In Another Tab
-
I have a rather unique situation and I don’t know if the solution is necessarily related to ACFE but I am using an ACFE form.
I’m using ACFE to call a custom function on form submit. This function is run after updating a Card Pack post type – it awards collectible Cards to users, and updates a hidden True/False field called ‘is_card_pack_opened’ to True. This then shows a different template for the Card Pack post, showing the Cards that were in the pack. This is all working fine. My issue is… I realised there’s nothing stopping users having the unopened Card Pack page open in another tab and clicking the button to basically be awarded the Cards twice, or even more if they have more than 2 tabs open.
I suppose I somehow need to stop the post being updated on the second tab if it’s already been updated – so if the ‘is_card_pack_opened’ is now true, but obviously without the page being refreshed in the other tab, it will still think the Card Pack is unopened. Is it actually possible to update the true/false field ‘live’ – through ajax presumably – and stop the form being submitted again? Or any kind of validation, perhaps even a limit on how many times a form/post can be updated and just set that to once only?
Appreciate any suggestions you might have. Thanks.
- The topic ‘Stopping Same Form Being Updated Twice In Another Tab’ is closed to new replies.