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

Fetch Forum ID by Thread ID in Non-Object


Active member
As the title says, I'm trying to fetch the forum id (node_id) by the 'thread_id'. I tried to use the $this->getModelFromCache['XenForo_Model_Forum'] method, so I could use getForumByThreadId, but I guess I can't do that where I'm trying to do it. I get the following error: Fatal error: Using $this when not in object context in /dirs/to/myAddon/Listener.php on line 165.

Is there a way to do this, somehow, without having to make another call to the dB?

Chris D

XenForo developer
Staff member
You're trying to use $this in your Listener which won't work because it's not in an object context.

Also, the getModelFromCache function won't be available in your Listener so trying to call it as if it is won't work.

The correct way to do this in a Listener is: