Page 1 of 1
[RESOLVED] Automatically Grouping Users.
Posted: Sat Apr 26, 2008 3:18 pm
by BlueLaw
Hi Everyone.
I am the admin of the site but I have a "webmaster" - who has less permissions than me.
When he adds new users they don't go into any group.
I don't want to give him access to be able to assign new users to a group, I want new users to automatically be added to the group "editors".
- Another problem... Once those new users are created I want their default administration theme to be "Glassy_Blue" - rather than the default cmsms theme. And also in User Preferences, I want "administration shortcuts" to be UNchecked, and "hide help links" to be checked.
Is this possible do you think? I'd love to know any ideas, and go easy on me, I'm new to this and code makes my eyes go crossed.
Willing to learn!
Talk soon.

Re: Automatically Grouping Users.
Posted: Sat Apr 26, 2008 3:52 pm
by calguy1000
You'd have to adjust that using a user defined tag that trapped the user added event.
so it would have to be done in php, but shouldn't be that hard to do.
Re: Automatically Grouping Users.
Posted: Sat Apr 26, 2008 4:59 pm
by BlueLaw
Great!
Thanks for this help. I've heard about User Defined Tags, but I don't really know much about them, so I'm going to go do some reading up.
If anyone has any ideas to help with this it would be much appreciated.
Be good.

Re: Automatically Grouping Users.
Posted: Sun Apr 27, 2008 3:45 pm
by BlueLaw
Ooo.
I'm finding this a bit beyond my means to be honest. Can anyone elaborate on what Calguy is saying here?
I'm happy to read stuff, I can't even see what I should be reading though.
Let me know, I might just give the webmaster the capacity to assign users to groups instead.
Cheers.
Re: Automatically Grouping Users.
Posted: Sun Apr 27, 2008 6:40 pm
by Pierre M.
Hello,
I try to elaborate a bit (I can't do much) :
Please read the doc about User Defined Tags (UDT), then about the Events Manager.
Then you need to program your UDT (launched by the user added event) which would make the user's updates you want (change group, change theme...) How ? I don't know, the dev API is in need of a reading.
Pierre M.
Re: Automatically Grouping Users.
Posted: Wed Apr 30, 2008 2:57 pm
by Nullig
Create a UDT that is run from the AddUserPost Event, that puts them in a particular group. The group_id depends on which group you want to use as the default:
Admin - 1
Editor - 2
Designer - 3
Of course, if you add groups with different permissions, you will have to look up the id.
In this example, the new user will be automatically added to the Editor group.
Create a UDT called set_user_group, with this code:
Code: Select all
global $gCms;
$db = &$gCms->db;
$group_id = 2;
$query = "SELECT * FROM ".cms_db_prefix()."users_seq";
$dbresult = $db->Execute($query);
if ($dbresult && $dbresult->RecordCount() > 0)
{
$row = $dbresult->FetchRow();
$user_id = $row['id'];
}
$query = "INSERT INTO ".cms_db_prefix()."user_groups (group_id, user_id, create_date, modified_date)
VALUES ($group_id, $user_id, ".$db->DBTimeStamp(time()).", ".$db->DBTimeStamp(time()).")";
$result = $db->Execute($query);
In the Admin panel, go to Extensions/Events and select the AddUserPost event. Select the set_user_group UDT from the drop down menu and click on the Add button.
Now, whenever you add a new user, they will be assigned to that group.
Nullig