A
A
AdNahim2015-10-20 14:20:55
MODX
AdNahim, 2015-10-20 14:20:55

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'];
    }
}

Thanks to!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AdNahim, 2015-10-20
@alexanderkx

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 question

Ask a Question

731 491 924 answers to any question