Search code examples
phpmodx

How to get a user by username in MODx?


I need to get a user object in MODx using the username. Or the profile by username. How can I do that?

I know how to do it by id.

I'm using MODx REvo.


Solution

  • $user = $modx->getObject('modUser', array(
        'username' => $username,
    ));
    
    if ($user) {
        $profile = $user->getOne('Profile');
    }