Lu Jia
Active member
I want to create a post with DataWriter and I'm using this code:
When I try this code it will return this error
The post will be created just a <p>text</p>, maybe I should do some function with the var.
Any suggestions?
Thanks in advance
PHP:
/** @var $threadModel XenForo_Model_Thread */
$threadModel = XenForo_Model::create('XenForo_Model_Thread');
$thread = $threadModel->getThreadById($news['thread_id']);
$writer = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
$writer->set('user_id', $user_id);
$writer->set('username', $username);
$writer->set('message', $text);
$writer->set('message_state', 'visible');
$writer->set('thread_id', $thread['thread_id']);
$writer->save();
$post = $writer->getMergedData();
return $post;
When I try this code it will return this error
PHP:
Invalid controller response from JvCMS_ControllerPublic_Blog_News::actionAddComment
XenForo_FrontController->_handleControllerResponse() in XenForo/FrontController.php at line 318
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
XenForo_FrontController->run() in /var/www/vhosts/gw2.tv/httpdocs/index.php at line 13
Any suggestions?
Thanks in advance