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

Documentation for alerts?

I have searched the XenForo forums and the internet, as well as looked through the code, and I cannot figure out how the alerts work!
Is there any kind of documentation on this, or can someone provide a quick tutorial on how to get an AlertHandler set-up and sending alerts, etc?

Well I figured it out. I was wondering if there was any easy way to alert users with a specific permission other than looping through all the users?
For anyone interested, I worked this out. Was kinda tricky, I had to loop through the xf_permission_entry table and get all the users and groups with the permission. I then fetched the users from the groups and alerted them. I also had to make sure that the permission wasn't denied anywhere. If anyone wants the code for it, PM me! :)
Could you elaborate on how alerts work? A "How to create custom alerts" tutorial would be a great addition to this board imo.


Well-known member
Bit late, but this post by Chris D was what helped me understand how alerts work and how to implement them successfully.

The process for this to work correctly is:
  1. A custom content type added to the xf_content_type and xf_content_type_field tables
  2. A custom AlertHandler class (you can check out the code for the default AlertHandlers, e.g. located in library/XenForo/AlertHandler/)
  3. Send the Alert using the correct static function (XenForo_Model_Alert::alert)
  4. Create a template which will take the format of alert_{content_type}_{action} e.g. alert_post_like is the correct template name if your content_type is named "post" and the action you've passed to the alert function is "like"
Without the above, it will not work properly. To be clear: It isn't just as simple as running some queries to insert the data directly. That just won't work, unfortunately :)
Bit late, but this post by Chris D was what helped me understand how alerts work and how to implement them successfully.
Yeah, that was what I figured it out from too I think.

A few things to remember: If the alert count goes up but the alert isn't shown, that means that you haven't set up your content type correctly. Remember that XenForo doesn't automatically add your content type, you need to run a query on install. This add-on helps create the content types and gives you the SQL queries to insert them in your installer.
Another easy way to figure it out is to look at an add-on that uses alerts and see how they do it.