Advertisement:

Author Topic: User groups selection on registration  (Read 35120 times)

Offline pisdoktor

  • Jr. Member
  • **
  • Posts: 241
  • Gender: Male
    • medical student's web site
User groups selection on registration
« on: April 21, 2005, 09:09:49 AM »
is there any way to user select our group on registration?
« Last Edit: April 23, 2005, 03:37:51 PM by andrea »
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Online Gary

  • Lead Customizer
  • SMF Super Hero
  • *
  • Posts: 17,317
  • Gender: Male
  • So this is the luck of the draw...
    • Gazmanafc on Facebook
    • garygadsdon on LinkedIn
    • @Gazmanafc on Twitter
    • The Bongo Comics Fan Forum
Re: User groups selection on registration
« Reply #1 on: April 21, 2005, 02:14:58 PM »
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.

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: User groups selection on registration
« Reply #2 on: April 21, 2005, 04:55:04 PM »
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
Code: [Select]
</tr><tr>
<td width="40%">
<b>', $txt[82], ':</b>
</td>
<td>
<input type="password" name="passwrd2" size="30" />
</td>
</tr>

Add after that
Code: [Select]
<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
Code: [Select]
if ($user_info['is_admin'])
$register_vars['ID_GROUP'] = empty($_POST['group']) ? 0 : (int) $_POST['group'];

Replace
Code: [Select]
$register_vars['ID_GROUP'] = empty($_POST['group']) ? 0 : (int) $_POST['group'];
Or, if you want that to be an "additional" group:

Find
Code: [Select]
'ID_POST_GROUP' => 4,
Add after that
Code: [Select]
'additionalGroups' => "'$_POST[group]'",
« Last Edit: April 21, 2005, 05:04:09 PM by Oldiesmann »
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline pisdoktor

  • Jr. Member
  • **
  • Posts: 241
  • Gender: Male
    • medical student's web site
Re: User groups selection on registration
« Reply #3 on: April 22, 2005, 06:08:47 AM »
thanx for useful informations ;) i try to do
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: User groups selection on registration
« Reply #4 on: April 22, 2005, 06:15:20 AM »
Oldiesmann, if I created my own form I could join the Administrators (1) group with your modifications.  You have to validate the value.

-[Unknown]

Offline pisdoktor

  • Jr. Member
  • **
  • Posts: 241
  • Gender: Male
    • medical student's web site
Re: User groups selection on registration
« Reply #5 on: April 22, 2005, 12:56:47 PM »
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

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: User groups selection on registration
« Reply #6 on: April 22, 2005, 02:39:18 PM »
Didn't think about that [Unknown]...

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

Find
Code: [Select]
$register_vars['ID_GROUP'] = empty($_POST['group']) ? 0 : (int) $_POST['group'];
Replace
Code: [Select]
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:

Code: [Select]
$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

Code: [Select]
<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
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline pisdoktor

  • Jr. Member
  • **
  • Posts: 241
  • Gender: Male
    • medical student's web site
Re: User groups selection on registration
« Reply #7 on: April 22, 2005, 02:55:45 PM »
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

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: User groups selection on registration
« Reply #8 on: April 22, 2005, 03:28:40 PM »
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
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline pisdoktor

  • Jr. Member
  • **
  • Posts: 241
  • Gender: Male
    • medical student's web site
Re: User groups selection on registration
« Reply #9 on: April 22, 2005, 08:21:01 PM »
thanx Oldiesmann  ;D
JoomlaTurkiye.net Web Admin - Joomla Support Specialist

Personal site: www.sonerekici.com

Offline Saku

  • Jr. Member
  • **
  • Posts: 305
  • Gender: Male
Re: User groups selection on registration
« Reply #10 on: November 05, 2005, 07:47:57 PM »
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

« Last Edit: December 06, 2005, 01:53:36 PM by Sakuragi »

Offline cfrancesco65

  • Newbie
  • *
  • Posts: 2
Re: User groups selection on registration
« Reply #11 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

Offline pisdoktor

  • Jr. Member
  • **
  • Posts: 241
  • Gender: Male
    • medical student's web site
Re: User groups selection on registration
« Reply #12 on: December 03, 2005, 10:31:42 PM »
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

Offline jesterhawk

  • Semi-Newbie
  • *
  • Posts: 18
  • Gender: Male
    • Ice-BreakerZ Ministries
Re: User groups selection on registration
« Reply #13 on: December 06, 2005, 12:39:16 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

Code: [Select]
<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

Offline jesterhawk

  • Semi-Newbie
  • *
  • Posts: 18
  • Gender: Male
    • Ice-BreakerZ Ministries
Re: User groups selection on registration
« Reply #14 on: December 17, 2005, 04:12:55 PM »
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

Offline jesterhawk

  • Semi-Newbie
  • *
  • Posts: 18
  • Gender: Male
    • Ice-BreakerZ Ministries
Re: User groups selection on registration
« Reply #15 on: December 17, 2005, 04:14:07 PM »
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

Offline GB

  • Newbie
  • *
  • Posts: 8
Re: User groups selection on registration
« Reply #16 on: January 19, 2006, 04:31:16 PM »
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
« Last Edit: January 19, 2006, 05:16:27 PM by GB »

Offline cfrancesco65

  • Newbie
  • *
  • Posts: 2
Re: User groups selection on registration
« Reply #17 on: March 29, 2006, 11:47:34 AM »
There isn't any news about this topic?!? I'm still waiting... :'(

Offline .Darkman

  • Full Member
  • ***
  • Posts: 508
  • Gender: Male
  • Templora.com
    • Templora
automatic
« Reply #18 on: June 05, 2006, 01:38:49 AM »
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