Notification icon indicating copy to clipboard operation
Notification copied to clipboard

(Custom) trigger not sending emails

Open mockmeup opened this issue 3 years ago • 2 comments

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

mockmeup avatar Feb 15 '22 14:02 mockmeup

Addendum: I deactivated all plugins besides "notification", and activated on of the standard themes (twentytwenty).

Same result:

  • with v7.2.4 the "page was updated" trigger results in emails being sent
  • while with v8.0.10 no mails are sent at all

So my current guess would be that either it's a bug in v8.0.10 or some kind of "incompatibility" with Wordpress v5.9 ...a

mockmeup avatar Feb 16 '22 10:02 mockmeup

Hey @mockmeup, if the notification is in the debug log, then there's not much else that can break.

Version 8 introduced a different way of processing the notification, so there are a few things to check:

  • Server's error log. Does it say anything about the Notification plugin?
  • Is your WordPress sending other emails? Ie. default password reset email.
  • Is the WP-Cron functioning as it should? Does it process the events? You can check that with Site Health in Tools menu

jakubmikita avatar Mar 04 '22 10:03 jakubmikita