Author Topic: add user to additional member group  (Read 4699 times)

Offline konqi

add user to additional member group
« on: August 21, 2008, 03:55:51 am »
Hi, I altered the code off the membergroup add to change is so that they can join an additional membergroup. Problem with this is it only allows to join 1 additional group. I would like users to be able to "pay" to join different groups as they wish.

So what would I need to alter in the primarymembergroup.php so that if a user is already part of an additional membergroup it will add the next one on without removing the old one?


Offline Echtrae

Re: add user to additional member group
« Reply #1 on: September 28, 2008, 03:20:55 am »
I'm not saying that this is the only way to do this, but this is how I handled it.

	
function 
onUse()

	
{

	
	
global 
$db_prefix$ID_MEMBER$item_info;

	
	


	
	
$result db_query("SELECT additionalGroups

	
	
	
FROM 
{$db_prefix}members

	
	
	
WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);

	
	
$row mysql_fetch_assoc($result);

	
	
$groups explode(",",$row['additionalGroups']);

	
	
if(!
in_array($item_info[1],$groups))

	
	
{

	
	
	
if(
count($groups) > 1)

	
	
	
	
$groups[] = $item_info[1];

	
	
	
elseif((
count($groups) == 1) AND ($groups[0] != ""))

	
	
	
	
$groups[] = $item_info[1];

	
	
	
else

	
	
	
	
$groups[0] = $item_info[1];

	
	
	
	


	
	
	
$add_grps implode(",",$groups);

	
	
	
$result db_query("UPDATE {$db_prefix}members

	
	
	
	
SET additionalGroups = '
{$add_grps}'

	
	
	
	
WHERE ID_MEMBER = 
{$ID_MEMBER}"__FILE____LINE__);

	
	
}

	
	
return 
'Added Member Group!';

	
}



It seems to work so far.

Offline Armin

Re: add user to additional member group
« Reply #2 on: September 29, 2008, 07:28:57 am »
Echtrae, I got an errror while trying that code, the error happened when i went to add or edit items. "syntax error, unexpected ';', expecting T_FUNCTION in ..."

I found a better working one here: http://www.daniel15.com/forum/index.php/topic,659.0.html
« Last Edit: September 29, 2008, 07:34:19 am by Armin »