<p>We got to the bottom of this issue and it turned out to be that the <code>SproutEmail_SubscribeEvent::validateOptions()</code> method was returning <code>false</code>. Updating this to ensure the options were being validated properly fixed the issue:</p>

<pre><code>public function validateOptions()
{
  return true;
}
</code></pre>

<p>We've updated the docs and will also more clearly document this in the <code>SproutEmailBaseEvent</code> class in the next release.</p>

CC BY-SA 3.0
2017-02-16T19:36:37.833Z
2017-02-16T19:36:37.833Z
Ben Parizek
<p>I'm creating a plugin called "Membership" to handle user subscriptions through Stripe. I want to use SproutEmail to handle notification.</p>

<p>I've created a custom event as per the Sprout instructions:</p>

<pre><code>&lt;?php
namespace Craft;

class SproutEmail_SubscribeEvent extends SproutEmailBaseEvent
{
    /**
     * Returns the qualified event name to use when registering with craft()-&gt;on
     *
     * @return string
     */
    public function getName()
    {
        return 'membership.onSubscribe';
    }

    /**
     * Returns the event title to use when displaying a label or similar use case
     *
     * @return string
     */
    public function getTitle()
    {
        return Craft::t('When a user subscribes to a membership plan.');
    }

    /**
     * Returns a short description of this event
     *
     * @return string
     */
    public function getDescription()
    {
        return Craft::t('Triggers after a user has subscribed.');
    }

    /**
     * Returns the data passed in by the triggered event
     *
     * @param Event $event
     *
     * @return mixed
     */
    public function prepareParams(Event $event)
    {
        return [
            'value' =&gt; $event-&gt;params['user']
        ];
    }
}
</code></pre>

<p>SproutEmail is picking this up and I can select it as a rule:</p>

<p><a href="https://i.sstatic.net/M2iPh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/M2iPh.png" alt="SproutEmail Rule"></a></p>

<p>I added a listener to my plugin for <code>membership.onSubscribe</code> to ensure it's working properly:</p>

<pre><code>craft()-&gt;on('membership.onSubscribe', function(Event $event) {
    MembershipPlugin::log('membership.onSubscribe was triggered.');
});
</code></pre>

<p>And it appears to be:</p>

<pre><code>2017/02/16 15:07:33 [info] [plugin] membership.onSubscribe was triggered.
in /home/vagrant/Code/sbl.loc/craft/app/etc/plugins/BasePlugin.php (65)
in /home/vagrant/Code/sbl.loc/craft/plugins/membership/MembershipPlugin.php (56)
in /home/vagrant/Code/sbl.loc/craft/plugins/membership/services/MembershipService.php (15)

******************************************************************************************************
</code></pre>

<p>However SproutEmail doesn't sent out any notification email and when I check the logs for the plugin there is no mention that my custom event was triggered.</p>

<p>Does anyone have any idea what the issue might be?</p>

<plugin-sproutemail>
Custom event not sending notification email
# Custom event not sending notification email

(Asked by: username_0 on 2017-02-16)

I'm creating a plugin called "Membership" to handle user subscriptions through Stripe. I want to use SproutEmail to handle notification.
I've created a custom event as per the Sprout instructions:
on
     *
     * @return string
     */
    public function getName()
    {
        return 'membership.onSubscribe';
    }

    /**
     * Returns the event title to use when displaying a label or similar use case
     *
     * @return string
     */
    public function getTitle()
    {
        return Craft::t('When a user subscribes to a membership plan.');
    }

    /**
     * Returns a short description of this event
     *
     * @return string
     */
    public function getDescription()
    {
        return Craft::t('Triggers after a user has subscribed.');
    }

    /**
     * Returns the data passed in by the triggered event
     *
     * @param Event $event
     *
     * @return mixed
     */
    public function prepareParams(Event $event)
    {
        return [
            'value' => $event->params['user']
        ];
    }
}

SproutEmail is picking this up and I can select it as a rule:

I added a listener to my plugin for membership.onSubscribe to ensure it's working properly:
craft()->on('membership.onSubscribe', function(Event $event) {
    MembershipPlugin::log('membership.onSubscribe was triggered.');
});

And it appears to be:
2017/02/16 15:07:33 [info] [plugin] membership.onSubscribe was triggered.
in /home/vagrant/Code/sbl.loc/craft/app/etc/plugins/BasePlugin.php (65)
in /home/vagrant/Code/sbl.loc/craft/plugins/membership/MembershipPlugin.php (56)
in /home/vagrant/Code/sbl.loc/craft/plugins/membership/services/MembershipService.php (15)

******************************************************************************************************

However SproutEmail doesn't sent out any notification email and when I check the logs for the plugin there is no mention that my custom event was triggered.
Does anyone have any idea what the issue might be?

**Tags:** plugin-sproutemail


---

## 1 answers

### Answer by username_1 on 2017-02-16. Score: 1

We got to the bottom of this issue and it turned out to be that the SproutEmail_SubscribeEvent::validateOptions() method was returning false. Updating this to ensure the options were being validated properly fixed the issue:
public function validateOptions()
{
  return true;
}

We've updated the docs and will also more clearly document this in the SproutEmailBaseEvent class in the next release.


---

