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

Alerting Staff Members when posting

Discussion in 'XenForo Development Discussions' started by Kirk, May 18, 2016.

  1. Kirk

    Kirk 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?
  2. Kirk

    Kirk 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');
    I think i'm doing my Alert handler wrong :(
  3. Chris D

    Chris D XenForo Developer Staff Member

    Have you created entries in the xf_content_type and xf_content_type_field tables?
  4. Kirk

    Kirk Well-Known Member

    I believe so. Is that done in the Installer?
  5. Chris D

    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.
  6. Kirk

    Kirk 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

Share This Page