Unable to create thread with html post message


New member
I am working on synchronizing news from a site and it's forum. So when an admin create some news on the site, a thread would be created in the forum as well. I used XenForo_DataWriter_Discussion_Thread for that.

$writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$writer->set('user_id', $oUser['user_id']);
$writer->set('username', $oUser['username']);
$writer->set('node_id', 2);
$writer->set('title', $aIns['name_article']);
$postWriter = $writer->getFirstMessageDw();
$postWriter->set('message', $aIns['content_article']);

The problem is the after creating a thread, the message is displayed with html tags.


How can i make it works properly without striping html tags ?

Chris D

XenForo developer
Staff member
Have you considered pulling the news content in automatically using RSS and Registered Feeds?

Chris D

XenForo developer
Staff member
Well, there's two things, really.

Yes, if you had the ability to create an RSS feed for your site (or if your site was built on a platform that supports RSS) then that would be quite easy because XenForo can read that automatically on a schedule, clean up the HTML (it converts it to bb code) and creates a thread in a forum.

However, if that isn't possible, you could at least look at the part of the XF code that converts the HTML to BB Code. Specifically:

$entry['content'] = XenForo_Html_Renderer_BbCode::renderFromHtml($html, array(
    'baseUrl' => $feed['baseUrl']

I should probably add: there are add-ons in the RM which allow HTML to be parsed inside a special BB code. That might also be an easy option.