• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Is there a function to send an alert to a user?

Stuart Wright

Well-known member
#1
I'm writing a php script for a php callback in a standard page. There is a circumstance where I need to send an alert to me to let me know of a particular situation.
Is there a quick way to send an alert to my account?
send_alert($user_id,$message) ?
 
S

Syndol

Guest
#2
$alertModel = $this->getModelFromCache('XenForo_Model_Alert');
$alertModel->alert($alertUserId, $userId, $username, $contentType, $contentId, $action, $extraData);
 

Stuart Wright

Well-known member
#3
$alertModel = $this->getModelFromCache('XenForo_Model_Alert');
$alertModel->alert($alertUserId, $userId, $username, $contentType, $contentId, $action, $extraData);
ooo many thanks David. Is there a resource which explains what the format and value of the parameters must adhere to?
 
S

Syndol

Guest
#4
This assumes you are using an existing content type which handles alerts.
If you wish to send alerts for custom types then you will need to create an add-on which fetches and displays your own content.
The simplest example would be to take a look at my Thread Ban add-on where I use alerts for my custom content type.
 
S

Syndol

Guest
#6
There is no alert function that will send any old text to a particular user.
If you want to notify a user about certain actions that exists in the system (such as replying, editing etc.) then you can use the default alert system by calling the alert function with appropriate action and content type.

Otherwise, to send an alert for your own 'action' you will need to create your own content type and alert handler. The alert handler fetches the content (if exists) and displays it together with the alert action.
 

Stuart Wright

Well-known member
#7
mmm. That's beyond me. I want to send an alert to me if a certain situation happens with data in a table. Maybe I'll just have the php script email me.
Thanks.