Bitrix Site Manager

OnBeforeUserUpdate

bool
event_handler(
 array &arParams 
);
The OnBeforeUserUpdate event is fired from the CUser::Update method before a user parameter changes, which can be used to cancel update or modify the user record fields.

Parameters

ParameterDescription
arParams An array of fields describing the user whose information is to be updated.

Note
All parameters passed to this handler function and the arParams array are references to original variables. Therefore, all changes to parameters made within the handler affect values of the original variables.

Return Values

To cancel update and terminate the CUser::Update method, raise an exception from within the handler using the method $APPLICATION->ThrowException() and return false.

See Also

  • OnAfterUserUpdate event
  • CUser::Update
  • Event handlers

    Example

    
    <?
    // file /bitrix/php_interface/init.php
    // register handler
    AddEventHandler("main", "OnBeforeUserUpdate", Array("MyClass", "OnBeforeUserUpdateHandler"));
    
    class MyClass
    {
        // create the "OnBeforeUserUpdate" event handler
        function OnBeforeUserUpdateHandler(&$arFields)
        {
            if(is_set($arFields, "LAST_NAME") && strlen($arFields["LAST_NAME"])<=0)
            {
                global $APPLICATION;
                $APPLICATION->throwException("Please type in the last name. (ID:".$arFields["ID"].")");
                return false;
            }
        }
    }
    ?>