Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Custom) trigger not sending emails #399

Open
mockmeup opened this issue Feb 15, 2022 · 2 comments
Open

(Custom) trigger not sending emails #399

mockmeup opened this issue Feb 15, 2022 · 2 comments

Comments

@mockmeup
Copy link

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 mockmeup added the bug label Feb 15, 2022
@mockmeup
Copy link
Author

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

@jakubmikita
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants