1. 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?

Discussion in 'Styling and Customization Questions' started by Stuart Wright, Nov 12, 2013.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    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) ?
     
  2. Syndol

    Syndol Guest

    $alertModel = $this->getModelFromCache('XenForo_Model_Alert');
    $alertModel->alert($alertUserId, $userId, $username, $contentType, $contentId, $action, $extraData);
     
  3. Stuart Wright

    Stuart Wright Well-Known Member

    ooo many thanks David. Is there a resource which explains what the format and value of the parameters must adhere to?
     
  4. Syndol

    Syndol Guest

    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.
     
  5. Stuart Wright

    Stuart Wright Well-Known Member

    I'm doing it from a php callback script for a page node.
     
  6. Syndol

    Syndol Guest

    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.
     
  7. Stuart Wright

    Stuart Wright Well-Known Member

    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.
     

Share This Page