A
A
Alexander Sinitsyn2017-10-06 18:49:18
1C-Bitrix
Alexander Sinitsyn, 2017-10-06 18:49:18

Why, after assigning login and email in OnBeforeUserUpdateHandler, they are not accepted by Bitrix?

Removed the login and email fields from the profile form. I put them in the event before changing the profile, they are filled in, visible in Before and After, but the profile is not saved and errors are displayed "Login must be at least 3 characters" and "Invalid E-Mail"
What's wrong?

AddEventHandler("main", "OnBeforeUserUpdate", "OnBeforeUserUpdateHandler");
function OnBeforeUserUpdateHandler(&$arFields)
{
    $arFields["ID"] = CUser::GetID();
    $arFields["LOGIN"] = CUser::GetLogin();
    $arFields["EMAIL"] = CUser::GetEmail();
}

AddEventHandler("main", "OnAfterUserUpdate", "OnAfterUserUpdateHandler");
function OnAfterUserUpdateHandler(&$arFields)
{
    var_dump($arFields);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Burlaka, 2017-10-06
@AlexeyGfi

You're reading them just as functions, not from the current user's specific object.
Try like this:

function OnBeforeUserUpdateHandler(&$arFields)
{
    global $USER;
    $arFields["ID"] = $USER->GetID();
    $arFields["LOGIN"] = $USER->GetLogin();
    $arFields["EMAIL"] = $USER->GetEmail();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question