yii2-user icon indicating copy to clipboard operation
yii2-user copied to clipboard

How to get Full Name?

Open joshcawthorne opened this issue 7 years ago • 2 comments
trafficstars

Hi, I'm trying to get a users full name (not username/email etc)

I've tried using "$fullusername = Yii::$app->profile->full_name;" however Yii throws an error saying it can't find the class. Is there an easy way to pass this info through to a view?

PS: Accidentally clicked enter after I wrote my title, sorry if I sent you an empty question!

joshcawthorne avatar Jan 05 '18 00:01 joshcawthorne

The full_name is set in the profile, so you would need to access the user -> profile. You can do that by using

$fullusername = Yii::$app->user->identity->profile->full_name;

where

user = Yii user component identity = User model profile = Profile model

amnah avatar Jan 05 '18 00:01 amnah

I see! That works, thanks for the exceptionally quick response!

joshcawthorne avatar Jan 05 '18 00:01 joshcawthorne