<p>You can write a simple <a href="http://pluginfactory.io" rel="nofollow noreferrer">plugin</a> that listens for the <a href="https://craftcms.com/docs/plugins/events-reference#entries-onSaveEntry" rel="nofollow noreferrer">onSaveEntry</a> event.</p>

<p>When that event fires, you plugin could check the <code>$isNewEntry</code> param to make sure it's a new entry being saved and also check the entry's section to make sure it's the front-end section you're expecting and might as well check <code>craft()-&gt;request-&gt;isSiteRequest()</code> to make sure it's a front-end request.</p>

<p>If all of those match, you would get the users in a group, then loop through all of them sending an email with <a href="https://craftcms.com/classreference/services/EmailService#sendEmail-detail" rel="nofollow noreferrer"><code>craft()-&gt;email-&gt;sendEmail()</code></a> for each user.</p>

<p>Something like (pseudocode):</p>

<pre><code>$element = craft()-&gt;elements-&gt;getElementType(ElementType::Users);
$element-&gt;group = 'groupHandle';
$users = $element-&gt;find();

foreach ($users as $user)
{
    // compose email body, header, etc.
    $success = craft()-&gt;email-&gt;sendEmail($email, $variables);
}
</code></pre>

CC BY-SA 3.0
2017-01-02T22:37:19.523Z
2017-01-02T22:37:19.523Z
Brad Bell
<p>I've used the front-end entry form in the docs to build a Q&amp;A portal, and it's working great. But I'd like to extend the functionality once the new entry is saved.</p>

<p>I've set the entries up to not be enabled when saved so that a moderation team can later approve them. Is there a way for members of the moderator user group to receive an email every time someone publishes a new question via the front-end form?</p>

CC BY-SA 3.0
2016-12-30T23:49:21.463Z
Are you posting these front-end entries to a custom plugin controller's action or are you going straight through Craft's `entries/saveEntry`?
Brad Bell
CC BY-SA 3.0
2017-01-02T17:04:27.790Z
I'm going through `entries/saveEntry`.
Jeremy Fuksa
<emails><entry-form>
Can I make the front-end entry form send an email to a user group?
# Can I make the front-end entry form send an email to a user group?

(Asked by: username_0 on 2016-12-30)

I've used the front-end entry form in the docs to build a Q&A portal, and it's working great. But I'd like to extend the functionality once the new entry is saved.

I've set the entries up to not be enabled when saved so that a moderation team can later approve them. Is there a way for members of the moderator user group to receive an email every time someone publishes a new question via the front-end form?

**Tags:** emails, entry-form

> **Comments:**
> **username_1**: Are you posting these front-end entries to a custom plugin controller's action or are you going straight through Craft's `entries/saveEntry`?  
> **username_0**: I'm going through `entries/saveEntry`.  

---

## 1 answers

### Answer by username_1 on 2017-01-02. Score: 2

You can write a simple plugin that listens for the onSaveEntry event.
When that event fires, you plugin could check the $isNewEntry param to make sure it's a new entry being saved and also check the entry's section to make sure it's the front-end section you're expecting and might as well check craft()->request->isSiteRequest() to make sure it's a front-end request.
If all of those match, you would get the users in a group, then loop through all of them sending an email with craft()->email->sendEmail() for each user.
Something like (pseudocode):
$element = craft()->elements->getElementType(ElementType::Users);
$element->group = 'groupHandle';
$users = $element->find();

foreach ($users as $user)
{
    // compose email body, header, etc.
    $success = craft()->email->sendEmail($email, $variables);
}


---

