Alerting Staff Members when posting


Well-known member
Hi everyone,

I'm trying to create an alert function that will be alert the staff when another staff member posts on a user's profile.

So what i'm trying to achieve with the alert is having it show up as "Staff Member A has created a Note on User's B profile".

I know I have to create an AlertHandler but I'm not sure what else i need to do. I know it has to getContents from a model (I think). Am i missing anything?


Well-known member
Here's what I got so far for my alert handler

class ElUsernotes_AlertHandler_Usernote extends XenForo_AlertHandler_Abstract
     * @param array $contentIds
     * @param XenForo_Model_Alert $model
     * @param int $userId
     * @param array $viewingUser
     * @return mixed
    public function getContentByIds(array $contentIds, $model, $userId, array $viewingUser)
        // TODO: Implement getContentByIds() method.
        $usernoteModel = $model->getModelFromCache('ElUsernotes_Model_Usernote');
        return $usernoteModel->getUsernoteByIds($userId, $contentIds);
I think i'm doing my Alert handler wrong :(

Chris D

XenForo developer
Staff member
Yes. You need a content type entry in the xf_content_type table then a alert_handler_class record in the xf_content_type_field table. You then need to rebuild that by removing the contentTypes record from the xf_data_registry table.


Well-known member
Alright so here is my content type stuff (I believe)

    protected $contentTypesAndHandlers = array(
        ElUsernotes_Model_Usernote::CONTENT_TYPE => array(
            'search_handler' => 'ElUsernotes_SearchHandler_Usernote',
            'moderator_log_handler_class' => 'ElUsernotes_ModeratorLogHandler_Usernote',
            'edit_history_handler_class' => 'ElUsernotes_EditHistory_Handler_Usernote'
So there i would put in my alert handler class and then later do a SQL query to insert into the table xf_content_type_field