1

I have a client that has a need for adding users without knowing their e-mail beforehand. Their wish is that when the user login for the first time, they are prompted to enter their e-mail, which also needs to be verified as normally by sending a activate link.

Is this possible to do?

Perhaps something hooked into the users.onBeforeSaveUser event?

4
  • How do they log in the first time? Is a username created when initially saving the user the first time?
    – Brad Bell
    Commented Aug 31, 2014 at 21:00
  • Yes, the admins would create the users as normally, from the cp. Commented Sep 1, 2014 at 7:49
  • For initial account creation, I frequently just use a plussed version of a utility email address, something like: [email protected]. That creates the user and just associates their account with an email that would get redirected to Gmail supports address plussing. You might need to check if your email provider does. For the rest of that process, I expect you'd need to do some plugin dev. Commented Sep 1, 2014 at 18:39
  • @BradBell Not sure if you got my reply, but i'm thinking Ben's reply might be worthwhile, if there is some way to tell Craft to verify the e-mail they enter, and also a way to check if they have verified, and not allow them past the verification screen before they do. Commented Sep 3, 2014 at 10:32

1 Answer 1

0

I think a custom plugin is going to be the best way to do this.

If the client is adding users from the control panel, they'll either have to put in a dummy email address ([email protected]), or you can create a front-end "user management" form for them that fills that in behind the scenes.

Regardless, you'll want to be sure "verify email address" is not enabled for the user at this point.

Then, assuming you'll be providing your own front-end login form for these users, with username/password fields (password not required), you'll want to point the form to your plugin's controller with it's own actionLogin method (very similar to Craft's UsersController->actionLogin), but check to see if password is null and if the username is valid and if the email is in the format of the unique email address that was previous assigned.

If so, prompt for their actual email, then send Craft's activation email and let it go through Craft's usual workflow for setting a password on the user account.

1
  • Thanks, sounds like a good way to do it! I'll dig into the existing code. Commented Sep 3, 2014 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.