handler function(
 array &arFields
The OnAfterUserRegister event fires after a new user login attempt by the CUser::Register method.


arFields Array of new user registration fields:
  • ID - if registration is successful, contains the new user ID
  • RESULT_MESSAGE - array with info text, describing the user registration result. Afterwards it is used by the ShowMessage function to display message.
  • LOGIN - user login name;
  • NAME - user name;
  • LAST_NAME - user last name;
  • PASSWORD - password;
  • CONFIRM_PASSWORD - password confirmation;
  • CHECKWORD - new checkword to change password;
  • EMAIL - user e-mail;
  • ACTIVE - active state flag [Y|N];
  • SITE_ID - the ID of default site used for notifications;
  • GROUP_ID - user groups ID array;
  • USER_IP - user ID address;
  • USER_HOST - user host name.

NoteAll parameters passed to this handler function are references to original variables. That is why its impossible to change these parameters: changes will not be saved. Actually, only RESULT_MESSAGE can be changed, which will lead to the change of the message, returned by the CUser::Register method. If user registration fields must be modified before saving, use the OnBeforeUserRegister event.

See Also:

Example of handler function:

// file /bitrix/modules/my_module_id/include.php
class MyClass
// create the event handler "OnAfterUserRegister"
public static function OnAfterUserRegisterHandler(&$arFields)
// if auth succeeds...
// if the current site is r1...
// set the message which confirms the registration within site r1
$arFields["RESULT_MESSAGE"]["MESSAGE"] = "You have successfully registered with site \"My site 1" \"My favourite site 1\"";
// set the message which confirms the registration within site r2
$arFields["RESULT_MESSAGE"]["MESSAGE"] = "You have successfully registered \"My favourite site 2\"";

return $arFields;

Example of handler function registration:

// register the event handler "OnAfterUserRegister"
RegisterModuleDependences("main", "OnAfterUserRegister", "my_module_id", "MyClass", "OnAfterUserRegisterHandler");

© «Bitrix24», 2001-2023