I have a User entries field called 'company'. I'm writing a bespoke plugin to manage users in the front-end and was wondering how I can access the content of this field in my plugin via the user model?
Any thoughts as struggling a wee bit here!
I have a User entries field called 'company'. I'm writing a bespoke plugin to manage users in the front-end and was wondering how I can access the content of this field in my plugin via the user model?
Any thoughts as struggling a wee bit here!
Response via Slack from Brandon Kelly:
Accessing custom field values from PHP is the same as in Twig - once you have the UserModel it's just
$user->myCustomFieldHandleor$user->myEntriesField->first(), etc.
Managed to get via following: $user->company->first()->title
$userrather than$entrybut with no success. Not sure if this is because am referencing an Entry field but proving difficult to see how to access contents. – Cole Henley May 18 '16 at 12:44