Resource icon

Using XF's alert system

asprin

Active member
asprin submitted a new resource:

Using XF's alert system - Tutorial on how to alert a user by using XF's alert repository

As part of an addon that I was developing, I had to alert a user once a certain condition was meant. While XF has made the alerting system very easy to understand, I still had to dig in significantly to grasp the concept. Thus, this tutorial is for those who are in the same boat as me.

Alerting basically is a 3-step process which as follows:

1. Trigger
First things first. You need to a trigger point, i.e when do you need to alert a user? It could be anything - like a...

Read more about this resource...
 
I see a notification message of that alert, but if I click on the alert icon, nothing is shown there
Code:
    $alertRepo->alert($sendTo, $sender->user_id, $sender->username, 'user', '', 'asprin_winner', array('title' =>'UEFA Cup', 'won'=>785874));
Is there anything else we have to do, to see the message there?
tempalte created alert_user_asprin_winner with content 1234, but still nothing shown.
 
Last edited:
I see a notification message of that alert, but if I click on the alert icon, nothing is shown there
Code:
    $alertRepo->alert($sendTo, $sender->user_id, $sender->username, 'user', '', 'asprin_winner', array('title' =>'UEFA Cup', 'won'=>785874));
Is there anything else we have to do, to see the message there?
tempalte created alert_user_asprin_winner with content 1234, but still nothing shown.
It seem to be, that you need to specify the content_id too, without it is not working.

Code:
    public function alert(
        \XF\Entity\User $receiver, $senderId, $senderName,
        $contentType, $contentId, $action, array $extra = [], array $options = []
    )

so after changing the code to this it worked:

Code:
    $alertRepo->alert($sendTo, $sender->user_id, $sender->username, 'user', $sender->user_id, 'asprin_winner', array('title' =>'UEFA Cup', 'won'=>785874));
 
Back
Top Bottom