Support Forum

Adding user to usergroup automatically

LI lisalew
lisalew
Member

When a user makes a purchase, he is automatically added to a usergroup using the following code (I pass the usergroup id through the url).  Anyway, it used to work in 5.0 alpha, but stopped working after I upgraded to beta.  Can you please tell me what’s wrong with it (I think the include paths are wrong..but I can’t figure out where they are now)…

 

<?php  $path = $_SERVER[‘DOCUMENT_ROOT’];    $path .= “/wp-content/simple-forum/library/sf-common-functions.php”;    include_once($path);

 $path1 = $_SERVER[‘DOCUMENT_ROOT’];    $path1 .= “/wp-content/simple-forum/library/sf-primitives.php”;    include_once($path1);

 $path2 = $_SERVER[‘DOCUMENT_ROOT’];    $path2 .= “/wp-content/simple-forum/library/sf-permissions.php”;    include_once($path2);

 $path3 = $_SERVER[‘DOCUMENT_ROOT’];    $path3 .= “/wp-content/simple-forum/library/sf-database.php”;    include_once($path3);

 

$usergroup_id=$_REQUEST[‘group’];

$user_id=$_REQUEST[‘userid’];   sfc_add_membership($usergroup_id, $user_id);

?>

Hey Chica! Thank you for joining our Celebrity Photographer’s 4-week Critique. You have been added to your photographer’s private classroom in the forum <a href=”http://<?php echo $_REQUEST[‘forumlink’]; ?>”>(http://<?php echo $_REQUEST[‘forumlink’]; ?>)</a>. You may need to logout and login again in order to see the posts.

6 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

That would never have worked in V5…

First problem is that the ‘simple-forum’ folder is named ‘simple-press’ in V5 so that accounts for the path problems.

Next however is that all of those included files are now different. Different names, different locations.

And finally the sfc_add_membership function, while needing the same two arguments, is now called sp_add_membership().

Depending on where you are calling this from then I think if you call the function:

sp_forum_ahah_support();

The that should load the support you need to call the add membership function.

LI lisalew
lisalew
Member

Ok, I upgraded again and now the code doesn’t work again.

 

Here is the code I’m using (I pass the group and userid through the url):

 

<?php sp_forum_ahah_support();

$usergroup_id=$_REQUEST[‘group’];

$user_id=$_REQUEST[‘userid’];

sp_add_membership($usergroup_id, $user_id);

?>

YS Yellow Swordfish
Yellow Swordfish
Member

Are you 100% that the usergroup and user IDs are being passed correctly? There have been no recent changes to the sp_add_membership() function.

LI lisalew
lisalew
Member

I think it may be a problem with s2member.  I upgraded their plugin and yours at the same time.  Thanks for the reassurance that you haven’t changed those functions.

YS Yellow Swordfish
Yellow Swordfish
Member

Let us know if we can help at all. For example where you need these values there may be a better way of getting them to you.

MP Mr Papa
Mr Papa
Member

right after your assignments to $user_id and $usergroup_id, try adding this:

vshow(‘uid = ‘.$user_id);

and

vshow(‘ugid = ‘.$usergroup_id);

should at least show us if the values are correct…  and please check forum – toolbox – error log and see if any errors preset…  you may want to clear it first, then try to make that code execute and look back at the error log…