A user has selected to watch all threads that they create and post in.
When I create a new post in a thread, the thread gets watched for that specific user
But when I create a new thread, it does not get watched
I have searched high and low, still can't find how to change if the thread is watched or not by a specific user. Any help?
When I create a new post in a thread, the thread gets watched for that specific user
Code:
$thread = \XF::em()->find('XF:Thread', $threadid);
$user = \XF::em()->find('XF:User', $userid);
$post = \XF::asVisitor($user, function() use ($thread, $message)
{
$creator = \XF::service('XF:Thread\Replier', $thread);
$creator->setMessage($message);
$creator->setIsAutomated();
return $creator->save();
});
But when I create a new thread, it does not get watched
Code:
$forum = \XF::em()->find('XF:Forum', $forumid);
$user = \XF::em()->find('XF:User', $userid);
$thread = \XF::asVisitor($user, function() use ($forum, $title, $message)
{
$creator = \XF::service('XF:Thread\Creator', $forum);
$creator->setDiscussionState('visible');
$creator->setContent($title, $message);
$creator->setIsAutomated();
return $creator->save();
});
I have searched high and low, still can't find how to change if the thread is watched or not by a specific user. Any help?