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
|
EndShowContentLicense: Showing the default license for content
|
||||||
- $action: the current action
|
- $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 = new Profile();
|
||||||
|
|
||||||
$profile->query('BEGIN');
|
|
||||||
|
|
||||||
if(!empty($email))
|
if(!empty($email))
|
||||||
{
|
{
|
||||||
$email = common_canonical_email($email);
|
$email = common_canonical_email($email);
|
||||||
|
@ -248,16 +246,8 @@ class User extends Memcached_DataObject
|
||||||
|
|
||||||
$profile->created = common_sql_now();
|
$profile->created = common_sql_now();
|
||||||
|
|
||||||
$id = $profile->insert();
|
|
||||||
|
|
||||||
if (empty($id)) {
|
|
||||||
common_log_db_error($profile, 'INSERT', __FILE__);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
|
|
||||||
$user->id = $id;
|
|
||||||
$user->nickname = $nickname;
|
$user->nickname = $nickname;
|
||||||
|
|
||||||
if (!empty($password)) { // may not have a password for OpenID users
|
if (!empty($password)) { // may not have a password for OpenID users
|
||||||
|
@ -282,6 +272,19 @@ class User extends Memcached_DataObject
|
||||||
$user->inboxed = 1;
|
$user->inboxed = 1;
|
||||||
|
|
||||||
$user->created = common_sql_now();
|
$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);
|
$user->uri = common_user_uri($user);
|
||||||
|
|
||||||
$result = $user->insert();
|
$result = $user->insert();
|
||||||
|
@ -328,6 +331,7 @@ class User extends Memcached_DataObject
|
||||||
$confirm->address_type = 'email';
|
$confirm->address_type = 'email';
|
||||||
|
|
||||||
$result = $confirm->insert();
|
$result = $confirm->insert();
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_log_db_error($confirm, 'INSERT', __FILE__);
|
common_log_db_error($confirm, 'INSERT', __FILE__);
|
||||||
return false;
|
return false;
|
||||||
|
@ -387,6 +391,9 @@ class User extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Event::handle('EndUserRegister', array(&$profile, &$user));
|
||||||
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue