Answer the question
In order to leave comments, you need to log in
How to automatically create a user profile from 1C?
I have buyers from 1C, but at the same time,
1. EXTERNAL_AUTH_ID is substituted for sale, because of this, the password does not allow me to enter
2. I write the following code in init.php to create a profile, it does not work:
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);
}
}}
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