Documentation

OnBeforeUserAdd

bool handler function(
   array &arParams 
);
The event OnBeforeUserAdd fires in the method CUser::Add before inserting a new user. It can be used to cancel the inserting or to re-define specific fields.

Parameters

ParameterDescription
arParams Array of fields for new user.

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

Returned value

To cancel user authorization and terminate the execution for the method CUser::Add, an exception must be thrown in the handler function via the method $APPLICATION->ThrowException() and return false.

See Also

Example of handler function:

<?
// file /bitrix/php_interface/init.php
// register the handler
AddEventHandler("main", "OnBeforeUserAdd", Array("MyClass", "OnBeforeUserAddHandler"));
class MyClass { // create event handler "OnBeforeUserAdd" public static function OnBeforeUserAddHandler(&$arFields) { if(strlen($arFields["LAST_NAME"])<=0) { global $APPLICATION; $APPLICATION->throwException("Please, enter the last name."); return false; } } } ?>


© «Bitrix24», 2001-2024