Documentation

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

ParameterDescription
arFields Array of fields for new user simple registration:
  • PASSWORD - password;
  • CONFIRM_PASSWORD - password confirmation;
  • CHECKWORD - password change checkword;
  • EMAIL - user e-mail;
  • ACTIVE - active state flag [Y|N];
  • SITE_ID - the ID of default site used for notifications;
  • GROUP_ID - array if user groups ID;
  • USER_IP - user IP address;
  • USER_HOST - user host name.
User is added and mail event NEW_USER is sent based on the array of fields.

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 method $APPLICATION->ThrowException() and return false.

See 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"
    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-2022
Up