Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Adding user to usergroup automatically
Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Jan 24, 2012 - 12:12 pm

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.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 24, 2012 - 12:35 pm

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Apr 4, 2012 - 11:19 am

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);

?>

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 4, 2012 - 12:13 pm

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Apr 4, 2012 - 2:34 pm

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.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Apr 4, 2012 - 2:46 pm

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.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Apr 4, 2012 - 8:17 pm

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...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626