XF 2.1 Sending Alerts From Addon

mjda

Well-known member
I've been at this for a good two hours with no luck.

PHP:
            $alertRepo = \XF::app()->repository('XF:UserAlert');
            $alert = $alertRepo->alertFromUser($alertUser, $visitor, 'transaction', $creator->transaction_id, 'create');

That is adding the alert into the database, and the notification bubble shows I have an alert, but when I click on it it still says "You have no new alerts.".

Also, when I click the page to add the transaction, I'm getting this error:

Code:
Error: Call to a member function getPushTemplateName() on null in src/XF/Service/Alert/Pusher.php at line 53

So, I assume there is no alert because I haven't specified a template, but I can't, for the life of me, figure out what the template is supposed to be called here, or how I can specify what it is.
 
You need an entity field and an alert_handler_class field for content type "transaction" in ACP > Development > Content types

For the alert to display, you have to create a public template called alert_transaction_create with a phrase.
 
You need an entity field and an alert_handler_class field for content type "transaction" in ACP > Development > Content types

For the alert to display, you have to create a public template called alert_transaction_create with a phrase.

Thanks for your reply! I had the alert_handler_class field, but didn't have an entity field. I'll give that a try and see what happens.

EDIT: Yep, worked like a charm. All this time wasted on a single entity field. 🤦‍♂️

Thanks for your help @Siropu...very much appreciated!
 
Last edited:
Top Bottom