-
-
Save aletoropov/7a0645bc79e80fc1ef631b5f04733699 to your computer and use it in GitHub Desktop.
Создание Super User-а для MODX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$username = 'vasya'; | |
$password = 'qwerty'; | |
$email = '[email protected]'; | |
$sudo = true; | |
require 'config.core.php'; | |
require MODX_CORE_PATH . 'model/modx/modx.class.php'; | |
$modx = new modX(); | |
if ((!$modx) || (!$modx instanceof modX)) { | |
echo 'Could not create MODX class'; | |
} | |
$modx->initialize('mgr'); | |
$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); | |
$user->setSudo($sudo); | |
if ($user->save()) { | |
echo 'Пользователь успешно создан'; | |
$user->joinGroup('Administrator'); | |
} else { | |
echo 'Не получилось создать указанного пользователя'; | |
} | |
} else { | |
echo 'Не получилось создать пользователя'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment