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

Link to a users latest thread in a specific forum

#1
We got an highly active journal forum, so most of the users got their own thread there. Are there some simple (non resource intensive) way to link to the users latest thread in that forum?
 

Jake Bunce

XenForo moderator
Staff member
#2
The latest post for each forum is linked on the index page. But that is a direct link by postid. There is no generic link for the last post in a forum.
 
#3
Guess another way to do it would be to run a hook when a user creates a thread there and update a custom user field (1.1). Can this be done? Didn't have a look at XenForo's hook system yet
 
R

ragtek

Guest
#4
I've needed something similar for my forum so i've coded an add-on for this.

PHP:
            public function actionIntroduceThread()
                    {
                        $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
                        $user = $this->_getUserModel()->getUserById($userId);
                        if (!$user) {
                            return $this->responseError(new XenForo_Phrase('requested_member_not_found'), 404);
                        }

                        $searchModel = $this->_getSearchModel();

                            $constraints = array(
                                'user' => array($userId),
                                'content' => 'thread',
                                'node'  => Ragtek_FW_Config::read('rit', 'node_id')
                            );

                            $searcher = new XenForo_Search_Searcher($searchModel);
                            $results = $searcher->searchGeneral('', $constraints, 'date', 1);

                        if (!$results) {
                            return $this->getNoSearchResultsResponse($searcher);
                        }

                        $search = $searchModel->insertSearch($results, 'user', '', array('user_id' => $userId), 'date', false);

                        return $this->responseRedirect(
                            XenForo_ControllerResponse_Redirect::SUCCESS,
                            XenForo_Link::buildPublicLink('search', $search),
                            ''
                        );
                    }
This code, will return the newest thread, from an user and from an special node.

I've placed this into the memebercontroller and linked on the member page ( http://localhost/xenforo/search/Introduce-Thread?user_id=1 )

It just needs some little tweeks (e.g. => redirect direct to thread instead of search results,etc...)
 

jgas

Active member
#5
Hi ragtek,
let's say that I want to display the latest 5 threads from a special node, and to display them in a custom tab of the profile .

Do I need to modify the php above?
What can I write on the html template code?

Thanks, have a nice day!
 
R

ragtek

Guest
#6
You want to display on all users profile the latest 5 user threads (including perm check) from node X ?
You wanna a add-on for 5$(because of my time:p ) for this?:D
 

jgas

Active member
#7
Sure! :D
Is it possible to show also the post content?
I want to display latest users "musical productions" so I thought it would be nice to display the post content with the embed players too.

I can pay up to 15 dollars.

Will it be a "standalone" addon or should I use the profile tab manager too?