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

I'm trying to create posts. And I'm very new to xenforo...

Discussion in 'XenForo Development Discussions' started by fly, May 5, 2014.

  1. fly

    fly Active Member

    I found an old thread that says pretty much how to do it here. However I'm assuming there are some includes or something required to actually make that code work enclosed in a standalone php script. Can someone explain what the full code might look like?

    $writer XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
    $writer->set('user_id', <userid of the poster>);
    $writer->set('username', <username of the poster>);
    $writer->set('node_id', <id of the node the thread is in>);
    $writer->set('title', <thread title>);
    $writer->set('prefix_id', <id of the thread prefix, if any>);
    $postWriter $writer->getFirstMessageDw();
    $postWriter->set('message', <thread contents>);

    $writer->save();//Thread is saved.
  2. Rigel Kentaurus

    Rigel Kentaurus Well-Known Member

    fly and rainmotorsports like this.
  3. fly

    fly Active Member

    That was exactly what I needed. Thanks!

Share This Page