I have a plugin that listens for the
users.onSaveUser. So when users register, an account is created, and I am creating an entry that will contain extended profile information. I am attempting to create a user field on that newly created entry to relate the entry back to the user account.
$entry = new EntryModel(); $entry->sectionId = 16; $entry->typeId = 1; $entry->enabled = false; $entry->authorId = $user->id; $entry->getContent()->title = craft()->request->getPost('firstName') . ' ' . craft()->request->getPost('lastName'); // userAccount is the handle of the user field. $entry->setContent(['fields' => ['userAccount' => $user->id]]); // nope. $entry->setContentFromPost(['userAccount' => $user->id]); // nope. ... craft()->entries->saveEntry($entry);
Everything is coming across except the user field. I'm not sure what the field needs/is looking for to set it's value.