Custom New Thread/Post Listener

in /library/XFtoWP/Listener/LoadClassController.php :
PHP:
class XFtoWP_Listener_LoadClassController {
    public static function loadClassListener($class, &$extend) {
        if ($class == 'XenForo_ControllerPublic_Thread') {
            $extend[] = 'XFtoWP_ControllerPublic_Thread';
        }
    }
}

in /library/XFtoWP/ControllerPublic/Thread.php :
PHP:
class XFtoWP_ControllerPublic_Thread extends XFCP_XFtoWP_ControllerPublic_Thread {
    public function actionAddThread() {
        $response = parent::actionAddThread();
        $new_thread=XenForo_Application::get('last_thread');
        $threadId = $new_thread['thread_id'];
// my code here...
        mail('me@example.com', 'Xenforo', 'Called and Executed');
       die('Called and Executed');
    }
}

A listener is setup as follows:
event: load_class_controller
Callback Class: XFtoWP_Listener_LoadClassController Method: loadClassListener
 
You haven't disabled listeners globally in the configuration, have you? And the add on is active?
 
Yes! That's exactly what I did! I used your tutorial. This one doesn't have any CP options or anything... its pretty simple.
 
Is the individual callback enabled? Nothing jumped out, but it should be throwing some type of error.
 
ok so now.. how would I grab the current Forum ID from this point? globals shows me only this: Array ( [_origRoutePath] => forums/main-forum.2/add-thread [node_id] => 2
 
Its most likely in the inputs. You should give a read through of XenForo_ControllerPublic_Forum::actionAddThread(); to see how its handled there.
 
You have access to the inputs in your extension:
PHP:
        $forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
 
Top Bottom