I am using the Import plugin. This question doesn't have to do with the Import plugin which seems to be working swell, but instead with my onBeforeSaveEntry logic which seems to have botched the import process.

public function init()

    craft()->on('entries.onBeforeSaveEntry', function(Event $event)

        if($params['isNewEntry']) {

            $entry = $event->params['entry'];

            $criteria = craft()->elements->getCriteria(ElementType::User);
            $criteria->groupId = 1;
            $criteria->AffiliateId = $entry['AffiliateId']; 
            $criteria->limit = 1;
            $users = $criteria->find();

            if (!empty($users)) {           
                $assignedCoach = $users[0]->id;
                $entry->authorId = $assignedCoach;
                $entry->getContent()->coachId = $assignedCoach;


What am I doing wrong here? Also, any idea how I kill the import processes which seem to be hung at the moment?


Your script probably chokes because you're interacting with an undeclared variable $params – i.e. change

if($params['isNewEntry']) {


if($event->params['isNewEntry']) {
  • That seems to be working, but now now the following line is not working. $entry->authorId = $assignedCoach; while $entry->getContent()->coachId = $assignedCoach; is working fine. Jan 25 '16 at 14:03
  • 2
    Okay, I found the answer to the last question I had on this thread regarding authorId here > craftcms.stackexchange.com/questions/6722/… Jan 25 '16 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.