I've added this
thread to "General Computing" forum too.
To me, the question looks more like language independent.
These trick works but I don't think it's the best approach.
It's not the worst either. It's simple and pretty straightforward and without seeing any additional requirements and the volume of such invites, I think that's a pretty good way to implement it.
Are there other requirements/considerations that you have in mind for considering an alternative approach?