We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22827
    • 129 Posts
    Hello,

    I have been trying to figure out a way to automatically generate a (temporary) userid when registering via webloginpe. The choices were to alter the form to add a hidden input field for a generated userid when the form is displayed, or to insert the temporary userid as the form details are saved to the database.

    This is because their "real" userid comes from elsewhere and so needs be altered later manually.

    Cleverly I decided to focus on adding the generated temp userid to the form details via a System Event plugin before it got saved. And by "cleverly" I mean the opposite. While webloginpe does call OnBeforeWebSaveUser, it only appears to provide the parameters it will use - there doesn’t seem to be a facility to change them in any way - they are not part of a global or object we can access. After lots of messing around, I gave up and tried the other end.

    But then I saw webloginpe doesn’t call any of the form generation system events. So I couldn’t see how to get the user into the form before it was rendered.

    But then, phx came to the rescue.

    I created a snippet called phx:tempuser which does nothing but return a unique user id.

    I then added
    <input type="hidden" name="username" value="[+phx:tempuser+]"/>
    into the registration template for the wlpe registration snippet.

    And of course, phx wins! So I figured I would post this here because it took far too long to figure out something so simple, and so others can tell me that there are infinitely easier ways to do this even than my approach to rub it in further.

    Cheers,

    Paul