D
D
Darklt2021-07-30 12:02:31
1C-Bitrix
Darklt, 2021-07-30 12:02:31

Why doesn't init work in Bitrix?

An event was created when adding a user through 1C to remove External=sale

In init.php :

AddEventHandler("main", "OnAfterUserRegister", "OnBeforeUserRegisterHandler"); 


    function OnBeforeUserRegisterHandler(&$arFields)
    {
    if(isset($arFields['EXTERNAL_AUTH_ID']))
    unset($arFields['EXTERNAL_AUTH_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" => 15,
               "NAME" => "Телефон",
               "VALUE" => $arFields['WORK_PHONE']
            ),
         array(
               "USER_PROPS_ID" => $PROFILE_ID,
               "ORDER_PROPS_ID" => 9,
               "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

1 answer(s)
R
Roman Gritsuk, 2021-07-30
@winer

Try the OnBeforeUserAdd event .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question