TomPich Posted September 11 Share Posted September 11 Hello processwirers, My client has a quite specific need and I have no clue about how to handle it. Visitors can buy events ticket on this site, but they don't have a client account (that’s part of the spec). Once they bought their ticket, all data are stored in an external database. If they want to check their booking, they have to enter their e-mail in an input field. From there : Processwire send them a mail with a single use url When client go to this page (no password requirement, so url must be like a hash), Processwire retrieve from the external database all the info needed) and display it. The page is deleted after a while (let say 24h) to avoid excessive amount of pages (about 10.000 visitors are expected) I’m okay with fetching data in an external database. My problems are: how to associate the email address to the temporary page url? how to handle the "temporary" aspect of these pages? Any help/suggestions/clues will be greatly appreciated... 😅 Thanks Link to comment Share on other sites More sharing options...
szabesz Posted September 11 Share Posted September 11 (edited) Hello, Just a few hints, as I do not have more time right now, but I hope this helps: 47 minutes ago, TomPich said: how to handle the "temporary" aspect of these pages? Use URL hooks: https://processwire.com/blog/posts/pw-3.0.173/ an to generate unique URLs, you can get inspiration from this helper method I use, for example: public static function getNewRandomUID(): string { $token = new Password(); $hash = $token->randomPass(["minLength" => 20, "maxLength" => 20, "maxSymbols" => -1]); return self::PREFIX_STRING . $hash . Tools::timestamp(); } Such a function can be enhanced by using uniqueNumber() from WireNumberTools: https://processwire.com/blog/posts/pw-3.0.213/ . 47 minutes ago, TomPich said: how to associate the email address to the temporary page url? I would save them in a database table row as text beforehand, so that they can be looked up when a visitor hits a given URL. Edited September 11 by szabesz typo 2 Link to comment Share on other sites More sharing options...
TomPich Posted September 11 Author Share Posted September 11 Thanks a lot @szabesz, that definitively enlightens me. I’ll give it a try when I come to this part. Again, thanks! 1 Link to comment Share on other sites More sharing options...
virtualgadjo Posted September 14 Share Posted September 14 Hi @TomPich i've often to do this kind of thing, typical example is a password reset link, in this case i usually create a personal db table with, worse than the case you describe, this page is limited to be viewed only one time... - auto increment id of course - user email - uid - creation date - used default 0 - used date (not necessary but i like to keep track of what happens) the page contains obviously a field to get the user email as soon as it is displayed - i check if the uid is in the db,, if not > die() and if the used field still contains 0 - the used field is set to one and it will not usable again (you may not need this limitation) the uid if of course a long (64char min) string easy to handle with pw url segments and a regex to define what you accept i've done this a lot, be it in pw but also in the old modx evo i used a long time ago as in all my framework based tools, pw just, as usual, makes it even easier to set up 🙂 of course, this is fully adaptable for any other need than password reset adding a user id field if you want to check the user email and password as well as what follows if the user is successfully logged in case it could be useful have a nice day 1 Link to comment Share on other sites More sharing options...
TomPich Posted September 14 Author Share Posted September 14 It definitely is useful. 😊 Thanks @virtualgadjo 1 Link to comment Share on other sites More sharing options...
virtualgadjo Posted September 14 Share Posted September 14 @TomPich my pleasure 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now