$warningDefinition = $this->finder('XF:WarningDefinition')
->where('warning_definition_id', $this->options()->EWRmember_mad_warning)
->fetchOne();
$warningFromUser = $this->finder('XF:User')
->where('user_id', $this->options()->EWRmember_mad_user)
->fetchOne();
if ($warningDefinition && $warningFromUser)
{
$warnService = $this->service('XF:User\Warn', $visitor, 'user', $visitor, $warningFromUser);
$warnService->setFromDefinition($warningDefinition);
if ($this->options()->EWRmember_mad_options['startc'])
{
$warnService->withConversation(
$warningDefinition->conversation_title, $warningDefinition->conversation_text, [
'open_invite' => $this->options()->EWRmember_mad_options['invite'],
'conversation_open' => !$this->options()->EWRmember_mad_options['locked']
]
);
}
$warnService->save();
}