We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41470
    • 3 Posts
    I'm relatively new to MODx and still learning the ropes in regards to registrations and logins, but I've almost gotten my client's login the way they requested.

    Essentially, the login should be simple and sweet. Part 1 is getting an "association" name (not relevant to this thread), Part 2 is acquiring username, email, and password, and Part 3 is logging in with username and password.

    My client wants the username and password to be auto populated in Part 3 based on what the user registered with in Part 2.

    What is the easiest way to take data from the previous page (Part 2) and auto-populate it in the fields on the next page (Part 3)?
      • 16348
      • 64 Posts
      I'm using this code as a post hook to the Register snippet. The code is based on the function in the ConfirmRegister snippet that authenticates a user upon confirmation of the registration.
      $user = $hook->getValue('register.user');
      if ($user == null) { return false; }
        
      $modx->user =& $user;
      $modx->getUser();
      
      $contexts = !empty($scriptProperties['authenticateContexts']) ? $scriptProperties['authenticateContexts'] : $modx->context->get('key');
      $contexts = explode(',',$contexts);
        foreach ($contexts as $ctx) {
        $user->addSessionContext($ctx);
      }
      
      return true;
      


      With this technique, the third step isn't necessary.
        • 41470
        • 3 Posts
        Very interesting! I am going to give this a try. The response is much appreciated.
          • 41470
          • 3 Posts
          Thank you very much, Kristoffer. Took me a little while, but I got it working. PHP isn't my strong-suit, but MODx is making it pretty easy to learn.