I'm building a plugin to add users to the system with set properties (like company) and permissions. The user form works with an "Entries" field and works with connected source section entries and works fine. Now when I receive the objects in my SiteAdministrator_UserService i'm trying to link the passed in companyId to the custom Entries field. Like this:
$lNewUser = new UserModel();
$lNewUser->status = UserStatus::Pending;
$lNewUser->firstName = $aUser->firstname;
$lNewUser->username = $aUser->username;
$lNewUser->lastName = $aUser->lastname;
$lNewUser->email = $aUser->emailaddress;
$lCompany = craft()->entries->getEntryById($aUser->companyId);
$lNewUser->getContent()->setAttributes(array(
'companiesDropdown' => $lCompany,
));
return craft()->users->saveUser($lNewUser);
$lCompany holds the entry of the company, that works fine. Now how do I link the $lCompany to the first entry in the custom Entries (companiesDropdown handle) field?
Just to clarify. All the above has nothing to do with an actual dropdown field. Thanks in advance