Registration (or email validation): Add user to a group
Permalink
I am trying to add a user to a group called "Clinic Members" when they register with my site.
I overrode the register.php and tried this (did not work)
Since the user registers by email activation, I also was thinking of trying to override login.php instead and add the user to a group inside of here:
The only thing is, how do I get the user object inside of that method? Unless there is a way to get the user id from the userinfo object (which I don't think there is...)
I overrode the register.php and tried this (did not work)
if (!$u->isError()) { //$this->redirect('/register', 'register_success', $rcID); $group = Group::getByName('Clinic Members'); $u->enterGroup($group); if(!$redirectMethod){ $redirectMethod='register_success'; $registerData['msg']=$this->getRegisterSuccessMsg(); } $registerData['uID']=intval($u->uID); }
Since the user registers by email activation, I also was thinking of trying to override login.php instead and add the user to a group inside of here:
public function v($hash = '') { $ui = UserInfo::getByValidationHash($hash); if (is_object($ui)) { $ui->markValidated(); // add user somewhere here $this->set('uEmail', $ui->getUserEmail()); $this->set('validated', true); } }
The only thing is, how do I get the user object inside of that method? Unless there is a way to get the user id from the userinfo object (which I don't think there is...)
The only thing is I don't want all new users to be signed up for that particular group.
I changed this in the do_register method and it worked too
I changed this in the do_register method and it worked too
$process = UserInfo::register($data); $user = User::getByUserID($process->getUserID()); $group = Group::getByID(5); $user->enterGroup($group);
http://www.concrete5.org/marketplace/addons/registrant-group/...