Can’t you do $modx->user->isMember(’usergroupname’) in the preHook?
shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect |
github |
splittingred.com
Is your computer telepathic?
I must be misunderstanding you, because before the user logs in, I can’t see any way to tell who the user is, much less which groups he or she belongs to.
Oh, wait, ha. Didn’t read that part.
No, there’s no way to tell what usergroup a user is in before the user logs in, because, well, the ’user’ in that sense doesn’t exist.
shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect |
github |
splittingred.com
-
☆ A M B ☆
- 2,475 Posts
Right... I would have to retrieve the username from $_POST and go from there.
Quote from: Everett at Jan 26, 2011, 10:02 PM
Right... I would have to retrieve the username from $_POST and go from there.
If the user hasn’t logged in, the only username you’ll ever get from anywhere will be ’(anonymous)’ and the user won’t belong to any groups.
Is it possible to assign a user automatically to a certain usergroup depending for example on his name or a number he types in while the register-process or profile-update? All the names and numbers which should be assigned to "Group A" will be stored by us in a database.
Is this feasible?
Letti
Yes, I think a plugin attached to OnUserFormSave could do that fairly easily. The username would be available as $user->get(’username’) and you can add the user to a group with $user->joinGroup(’groupname’).
The user is defined, but you need to get the user profile:
<?php
$profile = $user->getOne('Profile');
$profile->get('fax');
$newFax = '123-231-2211';
$profile->set('fax', $newFax);
$profile->save();