I'm using the following code in a php script to generate a forum thread:
What I'm trying to figure out is, is there a way to then get the new created thread's URL/ID so I can pass a link to another function?
Thanks.
Code:
$dir = WEBSITE_PATH.'/forums';
require($dir . '/src/XF.php');
XF::start($dir);
$forumId = '20'; //Forum ID of where to post thread
$userId = '2'; //User ID # of account to post thread as
$title = "Testing";
$message = '[b]Name:[/b] Test';
$forum = \XF::em()->find('XF:Forum', $forumId);
$user = \XF::em()->find('XF:User', $userId);
\XF::asVisitor($user, function() use ($forum, $title, $message)
{
$creator = \XF::service('XF:Thread\Creator', $forum);
$creator->setContent($title, $message);
$creator->setPrefix(1); //User ID # of account to post thread as
$creator->setIsAutomated();
$creator->save();
});
What I'm trying to figure out is, is there a way to then get the new created thread's URL/ID so I can pass a link to another function?
Thanks.