News:

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

Main Menu

Modify Usergroup

Started by MrLeN, April 28, 2011, 12:35:22 PM

Previous topic - Next topic

MrLeN

I would just like to let everyone to know that there's no flat file system. There's no text files. There's no referral system. There's no other login areas. I deleted it all. It doesn't exist and there's no way for me to get it back.  So we can forget all about that now. It's all gone, never ever to be seen again, by anyone in humanity, or elsewhere in the universe.

All I need is if someone goes to a certain URL, they get added to usergroup "9".

How can I do that?

emanuele

#41
For the first version mostly copied from Baby Daisy's first post, for the second one mostly copied from Subs-Member.php...

<?php
include_once('/PATH/TO/FORUM/DIRECTORY/SSI.php');

global 
$sourcedir$context;
require_once(
$sourcedir '/Subs-Members.php');

      
// $group_id should be whatever the id of the group you want to pass the member into
      
$group_id 9;

      
// $id should be passed as the ID of the member that requested the subscription
     
addMembersToGroup($context['user']['id'], $group_id);

That way the user need to be able to assign membergroups.

This doesn't need this permission:
<?php
include_once('/PATH/TO/FORUM/DIRECTORY/SSI.php');

global 
$sourcedir$context;
require_once(
$sourcedir '/Subs-Members.php');

      
// $group_id should be whatever the id of the group you want to pass the member into
      
$group 9;
if(!empty(
$context['user']['id'])){
     
$members=  array($context['user']['id']);
db_query("
UPDATE 
{$db_prefix}members
SET additionalGroups = IF(additionalGroups = '', '
$group', CONCAT(additionalGroups, ',$group'))
WHERE ID_MEMBER IN (" 
implode(', '$members) . ")
AND ID_GROUP != 
$group
AND NOT FIND_IN_SET(
$group, additionalGroups)
LIMIT " 
count($members), __FILE____LINE__);
}


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

MrLeN

wow, that's looking pretty much like what I need. Thanks :)

I can't tell if it works yet, because I have some stuff to do today, but I will check to see if it works later :)

However, something tells me that will work.

I just have one other problem.

How can I make a page that is only displayed to people in usergroup 1,2 or 9?

ie:

1 is administrators
2 is global moderators
9 is vip members

I want to say:

if (person is in usergroup 1,2 or 9) {
  echo "You can see this area..";
}
else {
  echo "You cannot see this area..";
}

..??

Baby Daisy

This is the script you want.

<?php
include_once('/PATH/TO/FORUM/DIRECTORY/SSI.php');

// $group_id should be whatever the id of the group you want to pass the member into
$group_id 9;

function 
add_to_group()
{
    global 
$context$user_info$scripturl$group_id;

    if (
$context['user']['is_guest'])
       
fatal_lang_error('no_access');

    if (
in_array(1$user_info['groups']))
       
fatal_error('You cannot move an admin out of their group!');

    
addMembersToGroup($context['user']['id'], $group_id);

    
redirectexit($scripturl);
}

add_to_group();
?>


To show specific content try using something such as;

if (in_array(9, $user_info['groups']))
echo 'content displayed to members in group 9!';
あなたは私のお尻にキスするとき、私はそれを愛する

Advertisement: