Author Topic: New Item: Add membergroup  (Read 22227 times)

Offline celadore

New Item: Add membergroup
« on: March 07, 2007, 07:17:30 am »
Save this as AddMembergroup.php under shop items.

I wanted to allow users to purchase additional membergroups.  The only solutions I found were the ChangeMembergroup in default SMF 3.0 and the BuyMembergroup by Chad (which didn;t work for me).  So I used both these to create a AddMembergroup item (I have only been using SMFShop for 20 minutes, but it appears to work for me).

What the Buyer gets:  The member who uses this item will have himself ADDED to the 1 membergroup for which the item was set-up for.  It will leave his primary membergroup unchanged.  The user does NOT get to choose which membergroup he wants to be added to NOR is he assigned to a random one.

Code: [Select]
<?php
//File: AddMembergroup.php
//      Item

//DATE: Mar 07, 2007
//Author Taj

class item_AddMembergroup extends itemTemplate {
    function 
getItemDetails() {
    
$this->authorName "Taj";

$this->authorWeb "http://www.hostadore.com/";

$this->authorEmail "admin@hostadore.com";

        
$this->name "Add Membergroup";
        
$this->desc "Allows you to add yourself to a membergroup!";
        
$this->price 1;

        
$this->require_input false;
        
$this->can_use_item true;
    }

    function 
getAddInput() {
global $db_prefix;

$selectBox '<select name="info1">';

// Get all non post-based membergroups
$result db_query("SELECT ID_GROUP, groupName
FROM 
{$db_prefix}membergroups
WHERE minPosts = -1"
,
__FILE____LINE__);

// For each membergroup, add it to the list
while ($row mysql_fetch_assoc($result)) {
$selectBox .= "<option value='{$row['ID_GROUP']}'>{$row['groupName']}</option>";
}

$selectBox .= "</select>";
        return 
"Membergroup: ".$selectBox;
    }
    

    function 
onUse() {
        global 
$db_prefix$ID_MEMBER$item_info;

$additionalGroups mysql_fetch_array(db_query("SELECT `additionalGroups` FROM {$db_prefix}members WHERE ID_MEMBER = {$ID_MEMBER}"__FILE____LINE__),MYSQL_ASSOC);

if(
$additionalGroups['additionalGroups']) {
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].", ".$item_info[1];
} else {
$additionalGroups['additionalGroups'] = $item_info[1];
}


echo 
$additionalGroups['additionalGroups'];          
        
$result db_query("UPDATE {$db_prefix}members SET additionalGroups = '{$additionalGroups['additionalGroups']}'
         WHERE ID_MEMBER=
{$ID_MEMBER}",__FILE____LINE__);

        return 
"You have joined new membergroup {$item_info[1]}!!";
    }
}
?>
« Last Edit: March 07, 2007, 05:26:10 pm by celadore »

Offline TechnoDragon

Re: New Item: Add membergroup
« Reply #1 on: March 07, 2007, 09:57:33 am »
the only issue I see (and i may be mistaken) is that you even allow them to choose the admin membergroup which could cause a serious security risk on a forum.
Don't tell me to get into shape...I have a shape...It is round!


Offline celadore

Re: New Item: Add membergroup
« Reply #2 on: March 07, 2007, 05:14:34 pm »
No, you are mistaken.  You either have not tried it out yet or you specified the admin group yourself when you set it up.

This item allows the buyer to be added to only 1 membergroup which the administrator chooses when he create the item.  When you set up this item in the admin, it asks you which membergroup you want the purchaser to be added to.  So it is PRE-SET!  The buyer is ONLY added to the membergroup that you have set the item up for and does NOT have the option to join any membergroup he pleases.

The good thing about this one is that you can create a different item for EACH membergroup you want your members to be able to BUY their way into and at DIFFERENT prices too! 

So no security leak here as far as I can see.
« Last Edit: March 07, 2007, 05:19:57 pm by celadore »

Offline feeble

Re: New Item: Add membergroup
« Reply #3 on: March 07, 2007, 07:04:48 pm »
nice item man, pretty clean code.
very nice

Offline TechnoDragon

Re: New Item: Add membergroup
« Reply #4 on: March 07, 2007, 09:35:09 pm »
No, you are mistaken.  You either have not tried it out yet or you specified the admin group yourself when you set it up.

This item allows the buyer to be added to only 1 membergroup which the administrator chooses when he create the item.  When you set up this item in the admin, it asks you which membergroup you want the purchaser to be added to.  So it is PRE-SET!  The buyer is ONLY added to the membergroup that you have set the item up for and does NOT have the option to join any membergroup he pleases.

The good thing about this one is that you can create a different item for EACH membergroup you want your members to be able to BUY their way into and at DIFFERENT prices too! 

So no security leak here as far as I can see.

Ok, my bad, I was just trying to read the code posted to see what it did, didn't notice that!  Very cool item then!
Don't tell me to get into shape...I have a shape...It is round!


Offline Sakuragi

Re: New Item: Add membergroup
« Reply #5 on: March 08, 2007, 02:42:41 am »
The BuyMembergroup by Chad (which didn;t work for me). 


It may work If you replace this
Code: [Select]
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].", ".$item_info[1];
By

Code: [Select]
$additionalGroups['additionalGroups'] = $additionalGroups['additionalGroups'].",".$item_info[1];

Offline CRONUS

Re: New Item: Add membergroup
« Reply #6 on: March 14, 2007, 03:07:30 pm »
So can anyone code it that member stays in group just for a time set by admin? :(
I understand it needs a cron job but my idea is to make Premium membergroup without ads, with unlimited PM box etc. ant if a member wants to stay in that membergroup, he/she has to buy it every month or week or...

Offline celadore

Re: New Item: Add membergroup
« Reply #7 on: March 14, 2007, 03:42:28 pm »
Sounds like a bit of a pain in the rear for your members to have to buy this every week or month, it would really p me off anyway if I had to do that unless being part of this special membergroup was absolutely essential (not just to get rid of ads and send PMs).

A simple solution would be to allow members to buy their way into the membergroup using this item and then purge the membergroup at the end of the month ready for next month.

To set-up a cron to do this for you does not require SMFShop in anyway, its to do with the Forum itself, so is kinda off topic.

If you are looking for something that logs the time when the person uses this item, counts down the time that he/she is a member of the member group and then removes them, you will probably have to hire a programmer to do that for you.  It's prob not difficult, but more than I would want to do :)


Offline SinekSekiz

Re: New Item: Add membergroup
« Reply #8 on: July 04, 2007, 02:05:29 am »
Hi Celadore

This is very nice item for sure and I might use it on my FRP based web site to sell people this membergroups as let say "house". : D For example I would name a member group as "Mountain farm" or "A Secret Cave" and sale it to my users. BUT I wonder when these guys buy this memeber group can they include some other members to it themself. Or after a user buy this group can other one buy an join in the member group whitout the first members permition.

It would be really nice for clan based FRP site. You could charge up to 99 members to join in to your memeber group. If it has these functions I would gladly install it.

But even like these this is a very good item.

Thanks for listening...
« Last Edit: July 04, 2007, 02:07:15 am by SinekSekiz »

Offline TomTheBig

Re: New Item: Add membergroup
« Reply #9 on: January 27, 2009, 09:11:39 pm »
Very nice Item!

hmmm... can you do a little modification?

i want, that they can buy the 'real' membergroup.

that the MAIN-group is changed, not just added to one.

hope you understand my bad english skills :)

thanks!

TomTheBig

Offline lovezaa

Re: New Item: Add membergroup
« Reply #10 on: January 28, 2009, 01:06:26 am »
Very nice Item! thanks!  ;)

Offline jonidfld

Re: New Item: Add membergroup
« Reply #11 on: June 12, 2009, 03:30:21 am »
So can anyone code it that member stays in group just for a time set by admin? :(
I understand it needs a cron job but my idea is to make Premium membergroup without ads, with unlimited PM box etc. ant if a member wants to stay in that membergroup, he/she has to buy it every month or week or...

Awe id really like this too - and thought maybe it can be done like the SMF Arcade passes for the SMFshop which allows access for a certain amount of time? Is there anyone who can look into this? Please....

 ;)


Offline Sakae

Re: New Item: Add membergroup
« Reply #12 on: June 21, 2009, 06:55:46 am »
Does this item works on new SA Shop for SMF 2.0 (since I know it's based on this MOD)?

Offline iKiller

Re: New Item: Add membergroup
« Reply #13 on: June 30, 2009, 05:32:44 am »
Sakae, SMFShop an SA Shop are two totally different mods. I looked in the code for SA Shop and didn't find much that was similar... Nice item though!

Offline Golovior

Re: New Item: Add membergroup
« Reply #14 on: August 26, 2009, 03:46:01 am »
Too bad this is an item for the older shop mods. I use shop version 3.1.4 and this item isn't working with it. When i add this item in the right directory i get a white screen on the add item page of the shop administration screen.

Couldn't solve it myself. Tried it for 2 days now. :(