6
ho provatoCome impostare Yii :: app() -> dall'utente> nome
public function getName()
{
return 'TEST';
}
in UserIdentity.php ma non sembra modificare il valore di Yii :: app() -> user-> nome
ho provatoCome impostare Yii :: app() -> dall'utente> nome
public function getName()
{
return 'TEST';
}
in UserIdentity.php ma non sembra modificare il valore di Yii :: app() -> user-> nome
Nella classe UserIdentity
definita, sarà necessario impostare un nuovo stato utilizzando il metodo setState(name, value)
.
Per esempio nel metodo authenticate
se l'utente è buono:
//if the user is good (good login and good password)
$this->_id=$record->id;
$this->setState('name', $record->name);
$this->errorCode=self::ERROR_NONE;
allora si sarà in grado di chiamare Yii::app()->user->name
Mentre questa domanda è per Yii1, ho scritto una risposta per h devo farlo in Yii2 correttamente. Nel caso in cui qualcuno che cerca Google per questo terre qui, leggi questo per Yii2: http://stackoverflow.com/questions/38415388/yii2-how-to-get-the-current-username-or-name-from-yiiapp- utente –