Create Vanilla Forum Discussions Programmatically
tsbvanillauser
New
I need to create vanilla forum discussions programmatically.
I have a php script which can create "title", "description" and category. Now I need a function to create discussions Programmatically.
Is it possible with Vanilla Forum?
Note 1: It is possible with WordPress using wp_insert_post() function.
Tagged:
0
Comments
Yes it's possible!
$DiscussionModel = new DiscussionModel(); $DiscussionModel->SpamCheck = FALSE; $DiscussionData = array( 'Name' => $StoryTitle, 'Body' => $StoryBody, 'CategoryID' => $CategoryID, 'Format' => $Format, 'DateInserted' => Gdn_Format::toDateTime($Timestamp), 'InsertUserID' => $UserID, 'UpdateCategoryID' => $CategoryID, 'DateUpdated' => Gdn_Format::toDateTime($Timestamp), 'UpdateUserID' => $UserID ); $InsertID = $DiscussionModel->Save($DiscussionData); $DiscussionModel->Validation->Results(TRUE);Thanks for your answer. I need to do this type of lots of thing. Is there any documentation to find something like this?
There is no specific documentation for that. But take a look at this plugin: https://vanillaforums.org/addon/datagenerator-plugin
It should be a good guide.