How do I put new users automatically into different groups when event wont fetch $u->getAttribute()?
Permalink
Hi,
I am trying to code an event that fires upon on_user_add... I would like to add the users to certain grooups depending on what they answer to a selectbox in the register form... this will not work out for me though, because I can't fetch any $u->getAttribute() from the just created user.. I can get anything else like $u->getUserEmail() and such, just not the getAttribute...
So am I doing anything wrong, or is there a better way to divide new members into different groups on registration... (I want them to be added to the group of their belonging apartment)
this is my code:
thank you in advance
I am trying to code an event that fires upon on_user_add... I would like to add the users to certain grooups depending on what they answer to a selectbox in the register form... this will not work out for me though, because I can't fetch any $u->getAttribute() from the just created user.. I can get anything else like $u->getUserEmail() and such, just not the getAttribute...
So am I doing anything wrong, or is there a better way to divide new members into different groups on registration... (I want them to be added to the group of their belonging apartment)
this is my code:
<?php class ApplicationUser extends Object { public function setupUserJoinInfo($ui) { Loader::model('groups'); $u = $ui->getUserObject(); $ui1 = UserInfo::getByID($u->getUserID()); // add new user to groups $g1 = Group::getByName('unvalidated'); if (is_object($g1)) { $u->enterGroup($g1); } if($ui->getAttribute('afdeling') == 'Ungdom') { $g2 = Group::getByName('Ungdom'); if (is_object($g2)) {
Viewing 15 lines of 39 lines. View entire code block.
thank you in advance
http://www.concrete5.org/community/forums/customizing_c5/problem-wi... Hopefully, this will help you.