Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = 'tempadmin';
- $password = 'sc00byd00';
- $email = 'tempadmin@domain.com';
- $sudo = false;
- /* Find out where the MODX core is */
- require "config.core.php";
- /* get the MODX class file */
- require MODX_CORE_PATH . 'model/modx/modx.class.php';
- /* instantiate the $modx object */
- $modx = new modX();
- if ((!$modx) || (!$modx instanceof modX)) {
- echo 'Could not create MODX class';
- }
- /* initialize MODX and set current context */
- $modx->initialize('mgr');
- /* load the error handler */
- $modx->getService('error', 'error.modError', '', '');
- $user = $modx->newObject('modUser');
- $profile = $modx->newObject('modUserProfile');
- if ($user && $profile) {
- $user->set('username', $username);
- $user->set('password', $password);
- $profile->set('blocked', 0);
- $profile->set('blockeduntil', 0);
- $profile->set('blockedafter', 0);
- $profile->set('email', $email);
- $user->addOne($profile);
- if ($sudo) {
- $user->set('sudo', true);
- }
- if ($user->save()) {
- echo "User Created";
- $user->joinGroup('Administrator');
- } else {
- echo "Could not create specified user";
- }
- } else {
- echo "Could not create a new user and/or profile object";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement