XF 2.0 Add attachment to post from PHP

_PkZ_

Active member
I am using this code to create a thread/post:
PHP:
\XF::asVisitor($user, function () use ($forum, $user) {
    $creator = \XF::service('XF:Thread\Creator', $forum);
    $creator->setContent("Test message", "Content of Test message");
    $creator->setIsAutomated();
    // ...
    $creator->save();
}

This works fine. Now i want to add an attachment to the post before saving (or after).
I have spent hours trying to figure out how to add attachments to the message without any luck. Anybody can point me i the right direction?
 
Ok, got it working by referring to the attachments data_id instead of content_id.
Is it safe to assume that data_id and content_id is the same?
 
Top Bottom