add hooks for user registration
This commit is contained in:
parent
2a054a50fb
commit
8cb8b357a4
|
@ -699,3 +699,12 @@ StartShowContentLicense: Showing the default license for content
|
|||
|
||||
EndShowContentLicense: Showing the default license for content
|
||||
- $action: the current action
|
||||
|
||||
StartUserRegister: When a new user is being registered
|
||||
- &$profile: new profile data (no ID)
|
||||
- &$user: new user account (no ID or URI)
|
||||
|
||||
EndUserRegister: When a new user has been registered
|
||||
- &$profile: new profile data
|
||||
- &$user: new user account
|
||||
|
||||
|
|
|
@ -209,8 +209,6 @@ class User extends Memcached_DataObject
|
|||
|
||||
$profile = new Profile();
|
||||
|
||||
$profile->query('BEGIN');
|
||||
|
||||
if(!empty($email))
|
||||
{
|
||||
$email = common_canonical_email($email);
|
||||
|
@ -248,16 +246,8 @@ class User extends Memcached_DataObject
|
|||
|
||||
$profile->created = common_sql_now();
|
||||
|
||||
$id = $profile->insert();
|
||||
|
||||
if (empty($id)) {
|
||||
common_log_db_error($profile, 'INSERT', __FILE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
|
||||
$user->id = $id;
|
||||
$user->nickname = $nickname;
|
||||
|
||||
if (!empty($password)) { // may not have a password for OpenID users
|
||||
|
@ -282,6 +272,19 @@ class User extends Memcached_DataObject
|
|||
$user->inboxed = 1;
|
||||
|
||||
$user->created = common_sql_now();
|
||||
|
||||
if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
|
||||
|
||||
$profile->query('BEGIN');
|
||||
|
||||
$id = $profile->insert();
|
||||
|
||||
if (empty($id)) {
|
||||
common_log_db_error($profile, 'INSERT', __FILE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
$user->id = $id;
|
||||
$user->uri = common_user_uri($user);
|
||||
|
||||
$result = $user->insert();
|
||||
|
@ -328,6 +331,7 @@ class User extends Memcached_DataObject
|
|||
$confirm->address_type = 'email';
|
||||
|
||||
$result = $confirm->insert();
|
||||
|
||||
if (!$result) {
|
||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||
return false;
|
||||
|
@ -387,6 +391,9 @@ class User extends Memcached_DataObject
|
|||
}
|
||||
}
|
||||
|
||||
Event::handle('EndUserRegister', array(&$profile, &$user));
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user