OnBeforeUserSimpleRegister
bool handler function( array &arFields, );The event OnBeforeUserSimpleRegister is called before a new user simple registration attempt by the method CUser::SimpleRegister. It can be used to terminate registration process or to re-define specific fields.
Parameters
Parameter | Description |
---|---|
arFields | Array of fields for new user simple registration:
|
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.
It allows, for example, to add additional registration fields into the fields or, for example, to define the LOGIN field - user login (otherwise, after user registration the login will be changed to user< new user ID >").
Returned value
To cancel user authorization and terminate the execution for the method CUser::SimpleRegister, throw an exception in the handler function via the methodSee Also
Example:
<? // file /bitrix/php_interface/init.php AddEventHandler( "main", "OnBeforeUserSimpleRegister", Array("MyClass", "OnBeforeUserSimpleRegisterHandler"), 100, $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/scripts/onbeforeusersimplereg.php" ); ?> <? // file /bitrix/php_interface/scripts/onbeforeusersimplereg.php class MyClass { // cre ate event handler "OnBeforeUserSimpleRegister" public static function OnBeforeUserSimpleRegisterHandler(&$arFields) { if (strpos($arFields["EMAIL"], "@mysite.com")===false) { global $APPLICATION; $APPLICATION->ThrowException("Registration is available only for e-mails in mysite.com" domain); return false; } } } ?>
© «Bitrix24», 2001-2023