I'm adding a function for "text evaluation" for new topics in a certain section of my forum dedicated to writing.
When submitting a new text (new topic in this session), a response will be given with the evaluation of that text.
Everything is apparently working, the only thing I couldn't do was set the poster_id
When a user creates a new topic, the response given comes with the same poster_id as the topic creator when it should come with poster_id = 60 according to the code.
Something appears to be overwriting the poster_id
Am I using the correct event for this?
Code: Select all
public static function getSubscribedEvents()
{
return [
'core.submit_post_end' => 'reply_avaliator',
];
}
public function reply_avaliator($event)
{
$data = $event->get_data();
$forum_id = (int) $data['data']['forum_id'];
$post_mode = $data['mode'];
$usergroup = (int) $this->user->data['group_id'];
$this->new_reply($forum_id, $topic_id, $post_title, $response);
}
public function new_reply($forum_id, $topic_id, $post_title, $response)
{
$reply_data = [
'forum_id' => $forum_id,
'topic_id' => $topic_id,
'topic_title' => $post_title,
'message' => $response,
'poster_id' => 60,
];
$poll_ary = null;
submit_post('reply', $post_title, '', POST_NORMAL, $poll_ary, $reply_data);
}