News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

User groups selection on registration

Started by pisdoktor, April 21, 2005, 09:09:49 AM

Previous topic - Next topic

pisdoktor

is there any way to user select our group on registration?
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Gary

In my opinion I dont think that would be pretty smart. If user's could select the group at regestration, they could chose Administrator and totally screw your forum up.
Gary M. Gadsdon
Do NOT PM me unless I say so
War of the Simpsons
Bongo Comics Fan Forum
Youtube Let's Plays

^ YT is changing monetisation policy, help reach 1000 sub threshold.

Oldiesmann

#2
Gaz - you would specify which group(s) a user could join. You wouldn't give them access to every membergroup on the board.

pis - this is actually relatively easy to do. The main issue here is whether you want the selected group to be a primary group (like Administrator, Global Moderator, Support Specialist, etc.) or a secondary group (where they would get all the permissions that the group gives them, but the group name would not be displayed any place and they wouldn't get special stars for being in that group).

First, you need to get the name and ID_GROUP value for each group you want them to be able to choose from. This can be done by hovering your mouse over the "modify" link next to each group in the "manage membergroups" section of your admin center and looking at the value of "id" in the URL.

In Register.template.php

Find
</tr><tr>
<td width="40%">
<b>', $txt[82], ':</b>
</td>
<td>
<input type="password" name="passwrd2" size="30" />
</td>
</tr>


Add after that
<tr>
<td width="40%">
<b>Group:</b>
</td>
<td>
<select name="group" size="30">
<option value="{group_id}">Group Name</option>
<option value="{group_2_id}">Group 2 Name</option>
...
</select>
</td>
</tr>


In Sources/Register.php:

If you want that to be a regular group:

Find
if ($user_info['is_admin'])
$register_vars['ID_GROUP'] = empty($_POST['group']) ? 0 : (int) $_POST['group'];


Replace
$register_vars['ID_GROUP'] = empty($_POST['group']) ? 0 : (int) $_POST['group'];

Or, if you want that to be an "additional" group:

Find
'ID_POST_GROUP' => 4,

Add after that
'additionalGroups' => "'$_POST[group]'",
Michael Eshom
Christian Metal Fans

pisdoktor

thanx for useful informations ;) i try to do
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

[Unknown]

Oldiesmann, if I created my own form I could join the Administrators (1) group with your modifications.  You have to validate the value.

-[Unknown]

pisdoktor

Oldiesmann thanx for your help ;) now another question,

how do i can show user groups automatically? i can not add a new group in register.template.php everytime :(
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Oldiesmann

Didn't think about that [Unknown]...

pis - modify the code I gave you above as follows:

Find
$register_vars['ID_GROUP'] = empty($_POST['group']) ? 0 : (int) $_POST['group'];

Replace
if($_POST['group'] == 1 && !$context['user']['is_admin'])
{
    $register_vars['ID_GROUP'] = 0;
}
else
{
    $register_vars['ID_GROUP'] = empty($_POST['group']) ? 0 : (int) $_POST['group'];
}


That will prevent anyone from making themselves admins :)

As far as automatically getting groups:

Add this to the register function in Register.php, right after the first "global" line:

$query = db_query("SELECT ID_GROUP, groupName FROM {$db_prefix}membergroups WHERE minPosts = '-1'", __FILE__, __LINE__);
$myarray = mysql_fetch_assoc($query);
foreach($myarray AS $group)
{
    // These are all the groups we don't want them to join (admin, global mod, moderator, etc.)
    if(in_array($myarray['ID_GROUP'], array('1', '2', '3'))
        continue;
    $context['groupstuff'] = array('ID' => $group['ID_GROUP'], 'name' => $group['groupName'],);
}
mysql_free_result($query);


Then, modify the code in Register.template.php as follows

Instead of manually typing a new line for each group, you could do something like this

<option value="', $context['groupstuff']['ID'], '">', $context['groupstuff']['name'], '</option>

I think that will work, but you might want to test it first to make sure.
Michael Eshom
Christian Metal Fans

pisdoktor

thanx  ;D i will test it...

at the same way can i add gender, location and birthday on registration?
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Oldiesmann

Yeah. Take a look at Register.php for more details. The only problem with birthdate though is the way its done - SMF has you input the month, day and year seperately, but it is stored as one value. You will probably want to copy the birthday validation stuff from Profile.php to handle that.
Michael Eshom
Christian Metal Fans

pisdoktor

JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Saku

#10
i have SMF 1.1 RC1 and i just replace this line

'ID_POST_GROUP' => 4,

by

'ID_GROUP' => X,

where X is the ID of the Regular group where i want the new members to be


cfrancesco65

How can I do the same with SMF 1.1?!? I take a look to Register.php but it seems to be quite different from 1.05 version...

Thanx

pisdoktor

Quote from: cfrancesco65 on December 03, 2005, 06:18:18 AM
How can I do the same with SMF 1.1?!? I take a look to Register.php but it seems to be quite different from 1.05 version...

Thanx

i have same trouble! i use smf 1.1 RC1 and i take a look register.php but i cant see anything to change...

Edit: i want to add gender and birthday info on registration ;)
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

jesterhawk

Quote from: Oldiesmann on April 22, 2005, 02:39:18 PM
Then, modify the code in Register.template.php as follows

Instead of manually typing a new line for each group, you could do something like this

<option value="', $context['groupstuff']['ID'], '">', $context['groupstuff']['name'], '</option>
Ok, I am new to the HTML/PHP coding, but trying to learn quick.  Where do I put this or how do I do this?  Please give me a little more info.

Thanks,
JH
-----------------------------------
Jesterhawk

jesterhawk

I hate to post this to bump this back up, but does anyone have an answer to my question just above this post?

Thanks,
JH
-----------------------------------
Jesterhawk

jesterhawk

Also, is there anyway that this could be made into a mod that someone not as skilled as PHP and HTML could install? That would also help when upgrades come out to keep everything working.

Thanks,
JH
-----------------------------------
Jesterhawk

GB

#16
I agree - I am sitting with the same problem.

Oldiesmann -

Thanks for your help. Is there a way to give a user to select multiple groups when signing up. I would like to give the user a range a choice of groups to join with a checkbox next to each choice.

Thanks

Guy

cfrancesco65

There isn't any news about this topic?!? I'm still waiting... :'(

.Darkman

i want the new users to be automatically classified into groups.
For example
the first member will be BLUE group
second will be GREEN group
third will be again BLUE group and so on...

Is there any way.

Clever Tutorials - One place for all of them . . .
SMF Theme Works



Advertisement: