$modx= new modX(); $modx->initialize('mgr'); echo('<html><pre>'); $query = $modx->newQuery('modUser'); $query->where( array('id'=> 1) ); $user = $modx->getObjectGraph('modUser', '{ "Profile":{}, "UserGroupMembers":{} }', $query); print_r($user ); die('Done</pre></html>');
This question has been answered by BobRay. See the first response.
/* Set path to MODX core directory */ /* be sure this has a trailing slash */ define('MODX_CORE_PATH', 'path/to/modx/core/'); /* get the MODX class file */ require_once MODX_CORE_PATH . 'model/modx/modx.class.php'; /* instantiate the $modx object */ $modx = new modX(); if ((!$modx) || (!$modx instanceof modX)) { die('Could not create MODX class'); } /* initialize MODX and set current context */ $modx->initialize('web'); // or $modx->initialize('mgr'); // in your case, it shouldn't matter /* load the error handler */ $modx->getService('error', 'error.modError', '', ''); /* Set up logging */ $modx->setLogLevel(xPDO::LOG_LEVEL_INFO); $id = 1; if ($modx->getObject('modUser', $id)) { die('User is there'); } else { die('User is not there'); }
id username primary_group active 1 (Username 1) 1 1 2 (Username 2) 2 1