/* This is assuming that you have the username and are *sure* it's a legit user */
$usr = $modx->getObject('modUser', array('username' => $username);
$modx->user =& $usr;
$modx->getUser();
/* optionally send contexts to log the user in to as a comma-separated list
in the &contexts property -- falls back to current context (e.g., 'web') */
$contexts = $modx->getOption('contexts', $scriptProperties, $modx->context->get('key'));
$contexts = explode(',', $contexts);
foreach ($contexts as $ctx) {
$modx->user->addSessionContext($ctx);
}
If you know it's the web context, you can skip the foreach and just use:
$modx->user->addSessionContext('web');
If you want to send the user somewhere after logging them in:
$docId = '12'; /* ID of the page you want to send them to */
$url = $modx->makeUrl($id, "", "", "full");
$modx->sendRedirect($url);