Created
March 1, 2021 09:09
-
-
Save kuntashov/2a47da22df994f8251d0a678245684ed to your computer and use it in GitHub Desktop.
Добавить пользователя битрикс в группу из консоли
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 | |
if ($argc < 4) { | |
die('Usage: bx_groupadd.php /path/to/site/document/root user_id group_id'.PHP_EOL); | |
} | |
$_SERVER["DOCUMENT_ROOT"] = $argv[1]; | |
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"]; | |
$userId = $argv[2]; | |
$groupId = $argv[3]; | |
define("NO_KEEP_STATISTIC", true); | |
define("NOT_CHECK_PERMISSIONS",true); | |
define("CHK_EVENT", true); | |
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); | |
@set_time_limit(0); | |
@ignore_user_abort(true); | |
$arGroups = CUser::GetUserGroup($userId); | |
$arGroups[] = $groupId; | |
CUser::SetUserGroup($userId, $arGroups); | |
echo "User $userId added to group $groupId" . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment