I've been stuck on this for the past day and I can't figure this out. I'm trying to setup a cron entry to send a conversation message but it's not working. When I checked the server error logs, I get this error:
The thing is, when I manually run this cron entry, it works perfectly. I'm assuming the Cron Entry function uses whatever account that runs the cron entry? I'm not sure. My code to the cron entry is shown below. Any help would be appreciate, thanks.
XenForo_Exception: You may not start a conversation with the following recipients: testuser. - library/XenForo/DataWriter.php:1345
Generated By: Unknown Account, 3 minutes ago
The thing is, when I manually run this cron entry, it works perfectly. I'm assuming the Cron Entry function uses whatever account that runs the cron entry? I'm not sure. My code to the cron entry is shown below. Any help would be appreciate, thanks.
Code:
$writer = XenForo_DataWriter::create('XenForo_DataWriter_ConversationMaster');
$writer->set('user_id', '10');
$writer->set('username', 'randomusername');
$writer->set('title', 'Test');
$writer->set('open_invite', '0');
$writer->set('conversation_open', '1');
$writer->addRecipientUserNames(array('testuser'));
$messageDw = $writerConv->getFirstMessageDw();
$messageDw->set('message', 'first message');
$writer->preSave();
if ($writerConv->hasErrors()) { return array('error' => TRUE, 'errors' => $writerConv->getErrors()); }
$writer->save();