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!
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.
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 11 years, 3 months ago.]
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.
UPDATE: Just found out that auto-generated password is available in the prehook, so I can email from there.