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

Need help triggering events based on thread prefix

Discussion in 'XenForo Development Discussions' started by Dannymh, Dec 1, 2014.

  1. Dannymh

    Dannymh Active Member


    I am looking at creating two custom code plugins for myself but not sure where to start. I am still learning xenforo from mybb.

    The two plugins need to trigger based on the prefix of the thread.

    So for instance if someone posts a thread with the prefix "news" I want the thread to need to wait for approval. In mybb I just parse the thread upon creation and then it works for me.
    But not sure even where to start on xenforo on this one

    The 2nd script will check the prefix when loading the thread or when created and pull extra information from a custom table.

    Really for now the first is the most important and i just need to know how I can check the prefix of a post and then do something with it based on that prefix.

  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Modify XenForo_DataWriter_Discussion_Thread (see: https://xenforo.com/community/resources/understanding-the-xenforo-class-proxy-system.2080/) and extend _discussionPreSave() to include something similar to this:

    if($this->get('prefix_id') == && !$this->isUpdate()) { $this->set('visibility''moderated'); }
    The second one you can modify XenForo_ControllerPublic_Thread::actionIndex() and modify the response to include your new params:
        public function actionIndex() {
    $response parent::actionIndex();
            if (
    $response->params['thread']['prefix_id'] == 0) {     
    $response->params['new_param'] = 'hello';
    Then use template modifications to include any necessary template changes.
    Dannymh likes this.

Share This Page