Answer the question
In order to leave comments, you need to log in
How to automatically create a user profile from 1C and remove it from the external sale group?
Colleagues, I'm asking for help, I'm importing users from 1C, for some reason they fall into the EXTERNAL_AUTH_ID = sale group, I have to manually delete them from the database. you can’t set a password for them in this case, then
I write in init.php to create a profile during registration, but it only works for manual registration.
AddEventHandler("main", "OnAfterUserRegister", Array("MyClass", "OnBeforeUserRegisterHandler"));
class MyClass
{
function OnBeforeUserRegisterHandler(&$arFields)
{
//создаём профиль
//PERSON_TYPE_ID - идентификатор типа плательщика, для которого создаётся профиль
$arProfileFields = array(
"NAME" => "Профиль покупателя (".$arFields['LOGIN'].')',
"USER_ID" => $arFields['USER_ID'],
"PERSON_TYPE_ID" => 3
);
$PROFILE_ID = CSaleOrderUserProps::Add($arProfileFields);
//если профиль создан
if ($PROFILE_ID)
{
//формируем массив свойств
$PROPS=Array(
array(
"USER_PROPS_ID" => $PROFILE_ID,
"ORDER_PROPS_ID" => 3,
"NAME" => "Телефон",
"VALUE" => $arFields['WORK_PHONE']
),
array(
"USER_PROPS_ID" => $PROFILE_ID,
"ORDER_PROPS_ID" => 1,
"NAME" => "Ф.И.О.",
"VALUE" => $arFields['LAST_NAME'].' '.$arFields['NAME'].' '.$arFields['SECOND_NAME']
)
);
//добавляем значения свойств к созданному ранее профилю
foreach ($PROPS as $prop)
CSaleOrderUserPropsValue::Add($prop);
}
}}
AddEventHandler("main", "OnAfterUserAdd", Array("MyClass", "OnBeforeUserAddHandler"));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question