Fetching user from a post

Gossamer

Active member
I've been trying to wrap my head around this, but I'm having trouble extending the ControllerPublic_Thread so that I can pull a variable into a post.

I have subaccounts installed on my forum and I'm creating an addon to display the parent account, if it exists, on the member card, the member info page, and the user info next to posts. It's the last one I'm having trouble with.

This is the code I've used for the member info page, for reference:
PHP:
    public function actionIndex()
    {
        $subModel = $this->_getSubModel();
      
        $response = parent::actionIndex();
      
        $response->params += array(
            'parent' => $subModel->getParentAccount($userId),
            'parentExists' => $subModel->ParentAccountExists($userId),
        );
      
        return $response;
    }

I'm trying to figure out how to extend ControllerPublic_Thread so I can fetch the $user of a post and pass it into my getParentAccount function. I've looked at a few addons to try and figure out how it was done elsewhere, but I can't seem to wrap my head around how the code digs from thread->post->user.

Any help would be greatly appreciated. :)
 
Been working on this the past two days, but haven't made any progress. Should I be perhaps looking at modifying the user model or post mode instead? Or can somebody point me to an add-on that has done this sort of thing?
 
Thanks! I've been taking a look at it, but it doesn't look like the plugin ever pulls in user information via php. That seems to only come into play with template modifications.

Though I don't know if you thought this part might help me?

From the Thread Controller:
PHP:
$signatureAdModel = $this->_getPostModel();

            $parent->params['defaultSignature'] = $signatureAdModel->getAdvertisement();

I'm just confused, because it calls the post model, but then the getAdvertisement function is actually in the thread model.
 
You seem to be right. I don't know why that is working(or the code is from an early prototype).
Actually the code was meant to help you in extending ControllerPublic Thread class.

If you want to get user information, try getting the data from one of the functions XenForo_Model_User
 
Back
Top Bottom