<p>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 <a href="https://craftcms.com/classreference/controllers/UsersController" rel="nofollow">UsersController</a> and possibly <a href="https://craftcms.com/classreference/services/UsersService" rel="nofollow">UsersService</a> by pointing your user registration form to your plugin's controller's registration action.</p>

<p>You'd <em>almost</em> 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.</p>

CC BY-SA 3.0
2016-09-29T13:34:11.630Z
That was exactly the route to go. Time to finally get into plugin development I guess.
Marcus Scheller
CC BY-SA 3.0
2016-09-29T13:41:37.700Z
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
CC BY-SA 3.0
2016-09-27T22:44:31.477Z
2016-09-27T22:44:31.477Z
Brad Bell
<p>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:</p>

<p>You'd have to write a very simple, custom plugin. For instant success, scaffold your plugin using the <a href="https://pluginfactory.io/" rel="nofollow">Plugin Factory</a>. Under <em>Plugin Components</em>, enable <a href="https://craftcms.com/docs/plugins/controllers" rel="nofollow">Controllers</a>.</p>

<p>Unzip and install your plugin.</p>

<p>In the Controller class, add something like the following method:</p>

<pre><code>public function actionSendActivationEmail()
{

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

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

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

}
</code></pre>

<p>To create <a href="https://craftcms.com/docs/plugins/controllers#linking-directly-to-controller-actions" rel="nofollow">a link to this controller action</a> in your template, do something like this:</p>

<pre><code>&lt;a href="{{ actionUrl('yourPluginHandle/sendActivationEmail', { id: user.id }) }}"&gt;Send activation email&lt;/a&gt;
</code></pre>

CC BY-SA 3.0
2016-09-29T13:34:30.770Z
Worked lie a charm. Pretty easy to understand, too.
Marcus Scheller
CC BY-SA 3.0
2016-09-27T22:55:15.527Z
2016-09-27T22:55:15.527Z
Mats Mikkel Rummelhoff
<p>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?</p>

<p>So ideal journey would be:</p>

<ol>
<li>The site owner creates new customer via the front end (no activation
mail sent)</li>
<li>The site owner does stuff on the site (preparing content
for the customer)</li>
<li>The site owner pushes a button on the customer’s
profile which fires off the activation mail to the customer</li>
<li>Profit</li>
</ol>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<users><frontend><registration>
Send activation mail from front end
# Send activation mail from front end

(Asked by: username_0 on 2016-09-27)

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.

**Tags:** users, frontend, registration

---

## 2 answers

### Answer by username_2 on 2016-09-27. Score: 4 | Accepted answer

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:
Send activation email

> **Comments:**
> **username_0**: Worked lie a charm. Pretty easy to understand, too.  

---

### Answer by username_1 on 2016-09-27. Score: 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](https://craftcms.com/classreference/controllers/UsersController) and possibly [UsersService](https://craftcms.com/classreference/services/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.

> **Comments:**
> **username_0**: That was exactly the route to go. Time to finally get into plugin development I guess.  
> **username_0**: 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.  

---

