Answer the question
In order to leave comments, you need to log in
How to get extra user fields via username?
Good day.
The input contains only the username .
How can I get the value of additional user fields? Everything is clear
through id :
$user = $this->modx->getObject('modUser', $uid);
if ($user) {
$extended = $profile->get('extended');
if ($extended) {
$u_field = $extended['user_field'];
}
}
Answer the question
In order to leave comments, you need to log in
Understood.
It is likely that it is not entirely correct, but still.
I first get the id through username, and then an additional field, as in the question.
$username = 'username';
$query = $modx->newQuery('modUser', array(
'username' => $username,
));
$query->select('id');
$userId = $modx->getValue($query->prepare());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question