[RESOLVED] Automatically Grouping Users.

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
BlueLaw
Forum Members
Forum Members
Posts: 42
Joined: Wed Jan 02, 2008 10:27 pm

[RESOLVED] Automatically Grouping Users.

Post 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.
:o
Last edited by BlueLaw on Fri May 02, 2008 11:26 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Automatically Grouping Users.

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
BlueLaw
Forum Members
Forum Members
Posts: 42
Joined: Wed Jan 02, 2008 10:27 pm

Re: Automatically Grouping Users.

Post 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.
:D
BlueLaw
Forum Members
Forum Members
Posts: 42
Joined: Wed Jan 02, 2008 10:27 pm

Re: Automatically Grouping Users.

Post 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.
Pierre M.

Re: Automatically Grouping Users.

Post 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.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Automatically Grouping Users.

Post 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
Last edited by Nullig on Wed Apr 30, 2008 3:25 pm, edited 1 time in total.
Post Reply

Return to “CMSMS Core”