RSS Feed/News Generate post reply with $message, $thread and $user

Status
Not open for further replies.

ENXF NET

Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Nov 13, 2018
Messages
34,215
Points
823

Reputation:

I found this to be the nicest way to create a new post (not from visitor, but from a user). How can I set $user here, as the class is protected?
PHP:

Code:
/** @var \XF\Service\Thread\Replier $replier */
$replier = \XF::app()->service('XF:Thread\Replier', $thread);
$replier->setIsAutomated();
$replier->setUser($user); // protected class so it does not work
$replier->setMessage($message);
$post = $replier->save();

Is there a simpler way to achieve this? Writing the post directly to the entity...

Read more

Continue reading...
 
Status
Not open for further replies.
Top