Skip to content

(Custom) trigger not sending emails #399

@mockmeup

Description

@mockmeup

I'm using version 7.2.4, and created a custom trigger (with an email carrier). Everything was working fine, the trigger was triggered, and mails where sent.

After updating to version 8.0.10 and re-working the code I now don't get any mails.

My code before the update

Code in "triggers.php"

class TriggerNotificationUpdateToAll extends \BracketSpace\Notification\Abstracts\Trigger
{
    public function __construct()
    {
        parent::__construct(
            'my_plugin/manual_trigger',
            'Update an alle schicken'
        );

        $this->add_action('trigger_notification_to_all', 10, 2);
        $this->set_group('Support');
        $this->set_description('Triggered with trigger_notification_to_all action.');
    }

    public function action()
    {
        // This trigger should always process.
    }

    public function merge_tags()
    {
        // This trigger doesn't include any Merge Tags.
    }
}

Code in function.php

add_action('notification/init', function () {
    require_once(get_template_directory() . '/resources/includes/notifications/triggers.php');
});

add_action('notification/elements', function () {
    $custom_trigger_1 = new TriggerNotificationUpdateToAll;
    notification_register_trigger($custom_trigger_1);
});

My code after the update

I would like to update to the current version, but I can't get it running.

New code in "triggers.php", as described here:

https://docs.bracketspace.com/notification/developer/triggers/custom-trigger


use BracketSpace\Notification\Abstracts\Trigger as AbstractTrigger;

class TriggerNotificationUpdateToAll extends AbstractTrigger 
{
    public function __construct()
    {
        parent::__construct(
            'my_plugin/manual_trigger',
            'Update an alle schicken'
        );

        $this->add_action('trigger_notification_to_all', 10, 2);
        $this->set_group('Support');
        $this->set_description('Triggered with trigger_notification_to_all action.');
    }

    public function context()
    {
        // This trigger should always process.
    }

    public function merge_tags()
    {
        // This trigger doesn't include any Merge Tags.
    }
}

New code in function.php

use BracketSpace\Notification\Register;
add_action( 'notification/init', function() {
    require_once(get_template_directory() . '/resources/includes/notifications/triggers.php');
    Register::trigger( new TriggerNotificationUpdateToAll() );
} );

So, the problem is that now there are no mails being sent.

If I turn notification logging on, then the log shows the notifications, so at least the trigger is triggered ... but, as I wrote, no mails are actually sent out.

I also tried using a built in trigger - like "Page updated" - but it's the same. The notification shows up in the log, but no mails are sent. (With v7.2.4 and the old code it's working / sending, and with v8.0.10 it's not!)

What am I missing?

Environment

  • PHP: 7.4
  • WordPress: 5.9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions