Bitrix Site Manager

OnAfterUserRegister event

event_handler(
 array &arFields
);

The OnAfterUserRegister event fires after an attempt of a new user registration by calling the method CUser::Register.

Parameters

ParameterDescription
arFields Array of new user registration fields:
  • USER_ID - if the registration succeeds, contains the user ID;
  • RESULT_MESSAGE - array containing the verification result description (can be passed to ShowMessage to display a message);
  • LOGIN - user login;
  • NAME - user first name;
  • LAST_NAME - user last name;
  • PASSWORD - password;
  • CONFIRM_PASSWORD - password confirmation;
  • CHECKWORD - new check word for password change;
  • EMAIL - user e-mail;
  • ACTIVE - active state flag [Y|N];
  • SITE_ID - the ID of default site used for notifications;
  • GROUP_ID - array of user group ID's;
  • USER_IP - user IP address;
  • USER_HOST - user host name.

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.

For example, this allows to modify the RESULT_MESSAGE, which will change message returned by the method CUser::Login.

See Also

Example



<?
// file /bitrix/modules/my_module_id/include.php
class MyClass
{
    // OnAfterUserRegister handler
    function OnAfterUserRegisterHandler(&$arFields)
    {
        // if auth succeeds... 
        if($arFields["USER_ID"]>0)
        {
            // if the current site is r1...
            if(SITE_ID=="r1")
            {
                // set the message which confirms 
                // the registration within site r1
                $arFields["RESULT_MESSAGE"]["MESSAGE"] =
                "You have successfully registered "
                "with site \"My site 1\"";
            }
            elseif(SITE_ID=="r2")
            {
                // set the message which confirms 
                // the registration within site r1
                $arFields["RESULT_MESSAGE"]["MESSAGE"] = 
                "You have successfully registered "
                "with site \"My site 2\"";
            }
        }
    }
}
?>

Example of handler registration


<?
// register the OnAfterUserRegister handler
RegisterModuleDependences("main", 
                          "OnAfterUserRegister", 
                          "my_module_id", 
                          "MyClass", 
                          "OnAfterUserRegisterHandler");
?>