News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Limit membergroup to primary only?

Started by khamseen, July 25, 2015, 11:28:41 PM

Previous topic - Next topic

khamseen

I'm curious if anybody has a way of limiting a membergroup so that it can only be assigned as a primary?

We run with five primary membergroups (not including admins) and I'm wanting to give people the option to switch between them at will, however if I simply make them 'Free' so they can pick and choose, they may not think to remove the previous membergroup association which could run into problems later on where we use checks for which membergroups people are in.

Ideally, if a membergroup could be set to 'primary only' then selecting a new 'primary only' membergroup would automatically remove them from their current membergroup. I'm just not sure if it's doable, or more accurately, if there's an easy way to do it.
"In hope we find despair and in despair we find truth." - Myself

Illori

you could use the visibility option and make the group visible, that makes it a primary group. i dont think the ability to change to another primary group would force the user to drop the other group the way you want. this would require a good bit of modding to get what you want.

khamseen

Yeah that's what I figured. Guess we'll just continue moving people around manually for now then. Thanks though for your reply.
"In hope we find despair and in despair we find truth." - Myself

margarett

I didn't really test this but I guess it should be easy...

Groups.php, find:
// Should it become their primary?
if ($row['primary_group'] == 0 && $row['hidden'] == 0)
$row['primary_group'] = $row['id_group'];
else
$row['additional_groups'][] = $row['id_group'];

Replace with:

// List of membergroups which are always primary
$membergroups1 = array(1, 2, 3, 4);
// Should it become their primary?
if (in_array($row['id_group'], $membergroups1) || ($row['primary_group'] == 0 && $row['hidden'] == 0))
$row['primary_group'] = $row['id_group'];
else
$row['additional_groups'][] = $row['id_group'];


Fill that array (1, 2, 3, 4) with the IDs of the membergroups that you wish to have always as primary and the rest of the logics should  work by itself. I hope :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

khamseen

Thanks, though that doesn't appear to be doing anything different. If they have no primary then it sets it as a primary. But if they already have a primary, it just adds it as a secondary like normal.
"In hope we find despair and in despair we find truth." - Myself

margarett

Did you test it or are you just looking at the code? Because I didn't :P
And did you correctly fill that array with the IDs of your groups?

I guess I need to actually try it...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

khamseen

Yeah I did actually try it. :P
I tried assigning the membergroups from both the admin panel, and via the users own (I have a test account which doesn't have admin) 'Group Membership' on their profile.
I did change out the IDs to the ones I'm wanting it to affect, which for reference were 99 through 104.
"In hope we find despair and in despair we find truth." - Myself

margarett

Ah no... That is only supposed to work in the group request interface.
So when a user requests membership to a group, if that group is the array, it is assigned as primary ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

khamseen

Ahhhhh, ok.

Tested it in that capacity now and it appears to work as intended. Sorry, that was my mistake assuming it would cover more areas.
Not exactly what I was going for, but it will still make life easier for myself and my moderators when it comes to handling primary member group transfer requests so thank you very much, it's appreciated! :D

Now back to trying to cross out some more of the 30+ things on my todo list before I finally get round to pushing out the upgrades to our live forum. 
"In hope we find despair and in despair we find truth." - Myself

Advertisement: