Задача: отправлять при регистрации более полную информацию о пользователе |
AddEventHandler("main", "OnBeforeEventAdd", "MyOnBeforeEventAdd"); function MyOnBeforeEventAdd(&$event, &$lid, &$arFields){ if(($event=="NEW_USER") && (empty($arFields["SECOND_NAME"]) || empty($arFields["PERSONAL_PHONE"]))){ $arFields["SECOND_NAME"] = ""; $arFields["PERSONAL_PHONE"] = ""; } elseif($event=="USER_INFO"){ if(intval($arFields["USER_ID"])>0){ $rsUser = CUser::GetByID($arFields["USER_ID"]); $arUser = $rsUser->Fetch(); $toSend = Array(); $toSend["EMAIL"] = $arFields["EMAIL"]; $toSend["USER_ID"] = $arFields["USER_ID"] ; $toSend["USER_IP"] = $arFields["USER_IP"] ?? ""; $toSend["USER_HOST"] = $arFields["USER_HOST"] ?? ""; $toSend["LOGIN"] = $arFields["LOGIN"]; $toSend["NAME"] = $arFields["NAME"]?? ""; $toSend["LAST_NAME"] = $arFields["LAST_NAME"] ?? ""; $toSend["SECOND_NAME"] = $arUser["SECOND_NAME"] ?? ""; $toSend["PERSONAL_PHONE"] = $arUser["PERSONAL_PHONE"] ?? ""; CEvent::Send("NEW_USER", "s1", $toSend); } } } |