A
A
Anumik2016-10-21 09:30:46
1C-Bitrix
Anumik, 2016-10-21 09:30:46

How to write a phone number in a profile during auto-registration (BITRIX)?

Good afternoon
The site has a minimally customized ordering component, the user fills in 5 fields, one of them is a phone number, but this number is not saved in the user profile.
I tried to write a handler, but it didn’t work for me, I almost didn’t encounter them, and with php I’m so-so
Here’s what I tried to use:

AddEventHandler("sale", "OnBeforeOrderAdd", "OnBeforeOrderAdd");
 function OnBeforeOrderAdd(&$arProps)
   {
    //  echo "<pre>";
    //  print_r($arProps);
    //  echo "</pre>";
    //  die();
    global $USER;
    $userID = $USER->GetID();
       $user = new CUser;
        $fields = Array(
        "PERSONAL_PHONE" => $arProps['ORDER_PROP']['3'],
        );
        $user->Update($userID, $fields);
   }

I assume that at the moment the handler is triggered, the user is not yet authorized and it is not possible to pull out $userID = $USER->GetID();
The $arProps['ORDER_PROP']['3']phone number entered into the form by the user is stored in

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Saifullin, 2016-10-21
@Shapito27

Look here https://dev.1c-bitrix.ru/community/webdev/user/168...

N
Nikita, 2016-10-21
@Rema1ns

Assume right) You need to either register and authorize the user before recording the order, and give the order a user ID, or search the filter for a user with this phone in already registered ones and authorize him

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question