OnBeforeUserRegister
bool handler function( array &arArgs );The event "OnBeforeUserRegister" is called before a new user registration attempt by the method CUser::Register and can be used to terminate the registration process or to re-define specific fields.
Note: function will be called also when registration is confirmed (event OnBeforeUserUpdate), where the LOGIN key is unavailable.
Parameters
Parameter | Description |
---|---|
arArgs | Array of registration fields for new users:
|
Note Array of values 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.
This allows, for example, to add additional new user registration fields or fields for NEW_USER mail event into the array arArgs.
if ( isset($args['LOGIN']) && ! preg_match("/^[-a-zA-Z0-9_]+$/", $args['LOGIN']) )
Returned value
To cancel user authorization and terminate the execution of the method CUser::Register, throw an exception by the methodSee Also
Example of handler function:
<? // файл /bitrix/modules/my_module_id/include.php class MyClass { // cre ate event handler "OnBeforeUserRegister" public static function OnBeforeUserRegisterHandler(&$arFields) { // if a user came under the adv campaign #34, if ($_SESSION["SESS_LAST_ADV_ID"]==34) { // add this user to group #3 $arFields["GROUP_ID"][] = 3; // add admin comment if (intval($_SESSION["SESS_ADV_ID"])>0) $arFields["ADMIN_NOTES"] = "Ad campaign #34 - direct visit"; else $arFields["ADMIN_NOTES"] = "Ad campaign #34 - return"; $arFields["SITE_ID"] = "ru"; } } } ?>
Example of handler function registration:
<? // register the event handler "OnBeforeUserRegister" RegisterModuleDependences("main", "OnBeforeUserRegister", "my_module_id", "MyClass", "OnBeforeUserRegisterHandler"); ?>
© «Bitrix24», 2001-2023