We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17851
    • 213 Posts
    Here's my scenario: I want to automatically allow users to register (activation=0) and automatically generate the password for them, and send an email once they've registered. I only see that an email is sent when activation=0. Basically, I want to send the same email that goes out when you manually create a user in the manager. If the Login.Register snippet doesn't do this, then I can do this via posthook. Can this be done? How?

    Thanks!
      Mark Macatee
      President
      Power 10 Solutions
      http://www.power10solutions.com
      • 17851
      • 213 Posts
      *bump*
        Mark Macatee
        President
        Power 10 Solutions
        http://www.power10solutions.com
        • 3749
        • 24,544 Posts
        You can do it with a postHook. I think the ActivationEmail extra would also work it the users are being activated.

        The Subscribe extra also sends an email to people when they register.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 17851
          • 213 Posts
          Thanks Bob.

          Only problem with a posthook is how do I send the unencrypted password? Does the MODX API let me do what the "send password via email" does in the Manager for a user? Reason I need to send the password is I'm not prompting the user to enter one on registration (&generatePassword=`1`)

          ActivationEmail only works if you manually activate a user from the manager.
          Subscribe doesn't appear to let me specify the user to automatically be activated (ie, no double opt-in)
          [ed. note: MacLonghorn last edited this post 10 years, 6 months ago.]
            Mark Macatee
            President
            Power 10 Solutions
            http://www.power10solutions.com
            • 3749
            • 24,544 Posts
            Good question. I think you could generate a password yourself and set it as the user's password:

            $user->set('password', $yourGeneratedPassword);

            That should just overwrite the one Register created.

            Subscribe, BTW, activates the user (and logs them in) as soon as they click on the link in the email.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 17851
              • 213 Posts
              Quote from: BobRay at Jan 15, 2014, 11:04 PM
              Good question. I think you could generate a password yourself and set it as the user's password:

              $user->set('password', $yourGeneratedPassword);

              That should just overwrite the one Register created.
              Ah yes, good idea. Thanks!
                Mark Macatee
                President
                Power 10 Solutions
                http://www.power10solutions.com
                • 17851
                • 213 Posts
                UPDATE: Just found out that auto-generated password is available in the prehook, so I can email from there.
                  Mark Macatee
                  President
                  Power 10 Solutions
                  http://www.power10solutions.com