Need help triggering events based on thread prefix

Dannymh

Active member
Hi,

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.

Dan
 
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:

PHP:
if($this->get('prefix_id') == 1 && !$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:
PHP:
    public function actionIndex() {
        $response = parent::actionIndex();
        if ($response->params['thread']['prefix_id'] == 0) {     
        $response->params['new_param'] = 'hello';
       }
        return $response;
    }

Then use template modifications to include any necessary template changes.
 
Back
Top Bottom