3

I am building a site where all the content (and users) are being managed using the front end. The site owner needs to invite customers to the site but would like to control the time when that customer receives his activation mail. Is that possible without having access to the control panel?

So ideal journey would be:

  1. The site owner creates new customer via the front end (no activation mail sent)
  2. The site owner does stuff on the site (preparing content for the customer)
  3. The site owner pushes a button on the customer’s profile which fires off the activation mail to the customer
  4. Profit

I could just have my client send out a password reset mail (?) but that seems a bit hack-ish and raises security concerns since that form needs to be publicly available.

There are no methods available which are giving me access to the verification code so that route wasn’t successful either. Is there a way to grab that code and serve it to the template? That would do it for me.

Is there another way to make that happen? It might actually be easy to solve. I would be grateful if someone could push me in the right direction.

4

I'll focus on the "sending an activation email from the front end" part of your question, since that seems to be the crux of it:

You'd have to write a very simple, custom plugin. For instant success, scaffold your plugin using the Plugin Factory. Under Plugin Components, enable Controllers.

Unzip and install your plugin.

In the Controller class, add something like the following method:

public function actionSendActivationEmail()
{

    // Get the user from the `id` URL parameter
    $user = craft()->users->getUserById(craft()->request->getParam('id'));

    if ($user) {
        // Send the activation email
        craft()->users->sendActivationEmail($user);
    }

    // Redirect back to the page we came from
    $this->redirect(craft()->request->getUrlReferrer());

}

To create a link to this controller action in your template, do something like this:

<a href="{{ actionUrl('yourPluginHandle/sendActivationEmail', { id: user.id }) }}">Send activation email</a>
  • Worked lie a charm. Pretty easy to understand, too. – Marcus Scheller Sep 29 '16 at 13:34
2

Since this is on the front-end of a site, you can create a plugin that mimics as much of or as little of the default Craft user registration workflow as you want in UsersController and possibly UsersService by pointing your user registration form to your plugin's controller's registration action.

You'd almost be able to pull this off with native functionality, but by unchecking "Verify Email Addresses?" under Settings->Users->Settings in the control panel, Craft will (by default) set the user account's status to active on user registration, which it doesn't sound like is what you're going for.

  • That was exactly the route to go. Time to finally get into plugin development I guess. – Marcus Scheller Sep 29 '16 at 13:34
  • Btw. turning off “Verify Email Addresses?” would prevent me from indicating that the customer hasn’t logged in yet, right? Which is important to the site owners UX. – Marcus Scheller Sep 29 '16 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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