Hi,
I'm running into an issue extending the Forum class - what I'm trying to achieve is to automatically add a reply after a thread is created. I'm trying to extend the "finalizeThreadCreate" method in the Forum class.
I have some code which is currently doing nothing as far as I can tell. Two questions on this:
1. Should I be approaching this differently?
2. How can I best debug class extensions to determine where the issue is?
	
	
	
		
				
			I'm running into an issue extending the Forum class - what I'm trying to achieve is to automatically add a reply after a thread is created. I'm trying to extend the "finalizeThreadCreate" method in the Forum class.
I have some code which is currently doing nothing as far as I can tell. Two questions on this:
1. Should I be approaching this differently?
2. How can I best debug class extensions to determine where the issue is?
		PHP:
	
	class Forum extends XFCP_Forum
{
    protected function finalizeThreadCreate(\XF\Service\Thread\CreatorService $creator)
    {
        parent::finalizeThreadCreate($creator);
        $forum = $creator->getForum();
        $HelperForumId = $this->options()->sysnatHelperBotForumId;
        if($forum->node_id == $HelperForumId){
            $userId = $this->options()->sysnativeHelperBotUserId;
            $thread = $creator->getThread();
            $user = \XF::em()->find('XF:User', $userId);
            $message = $this->error(\XF::phrase('sysnative_helper_bot_first_post'));
            \XF::asVisitor($user, function () use ($thread, $message) {
                $replier = \XF::service('XF:Thread\Replier', $thread);
                $replier->setMessage($message);
                $replier->setIsAutomated();
                $replier->save();
            });
        }
    }
} 
 
		
 
 
		 
 
		 
 
		 
 
		