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
Password Protect forum?
Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Sep 21, 2011 - 11:18 am

I am using s2member, which integrates great with simple press.  However, I want people to be able to purchase access to one or more forums.  I can't use roles to determine usergroup, because a person can only have one role at a time.  I could manually add each member to a usergroup, but this could be extremely tedious (several will sign up each day, and it will be hard to match a username with a paypal purchase, etc).  Is there a way I could just password-protect a board so that I could give a password out to everyone who is supposed to access it, instead of basing access on wp role?

 

If it can't be password protected, is there a function that I could use that would add a username to a usergroup? s2member allows me to redirect to a url after successful purchase, so maybe I could pass a username and it could be added to the correct usergroup?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 21, 2011 - 11:41 pm

you can password protect any wp page... that is built into wp...  just edit the wp page the forum appears on and choose to password protect it...

if you want to password protect each individual forum, you will need to use usergroups and permissions to accomplish this...

yes, absolutely there is an api for adding members to a usergroup...  just use:

sfc_add_membership($usergroup_id, $user_id);

in 5.0, with full plugin api, you could probably write a short plugin to help you out...

Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Sep 22, 2011 - 3:21 pm

I want to use this: sfc_add_membership($usergroup_id, $user_id);

to add a user id to a usergroup after a successful paypal purchase.  I will be able to get the user id from the query string in my success page url (myreturn url is ="my-thank-you-page/?userid=%%user_id%%").  So would I simply use the following syntax in my success page (after installing a plugin that allows php in posts). 

 

<?php

      $usergroup_id=xyz;

      $user_id=$_REQUEST['userid'];

     

      sfc_add_membership($usergroup_id, $user_id);

     

      ?>

 

This seems too easy, but it would be great if it worked!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 22, 2011 - 11:53 pm

couple things... 

usergroup id will be an integer number...

if your are going to get the user id from $_REQUEST, make sure you sanitize it before calling the add membership routine so someone doesnt try some sql injection on you...

Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Sep 27, 2011 - 1:16 pm

I really appreaciate your help because I know this level of support isn't part of the bargain.  I'm not able to find where this function sfc_add_membership() is defined (I ran a search on the simple press files, and it isn't coming up for some reason).  I'm not familiar with php, but once I find the function, can I just copy and paste it above the code (in the post above) in my php file, and then save my file anywhere?  Or do I need to incorporate it into the simple press plugin by using the "hooks" you've mentioned before? 

 

Maybe there is a php programmer out there who I could pay to do this since I'm so clueless....

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 27, 2011 - 8:08 pm

its in simple-forum/library/sf-common-functions.php

you will want to include that file and then call the function with your arguments for the usergroup id you want to insert into and the user id of the user...

Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Sep 27, 2011 - 10:08 pm

THANK YOU!  I can't even believe how awesome your support is!

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Sep 27, 2011 - 11:31 pm

np. glad to help. Thanks for the kind words!  good to hear now and then!

Avatar
lisalew
Member
Free Members
sp_UserOfflineSmall Offline
Nov 1, 2011 - 12:13 am

I am using this function, sfc_add_membership(), to automatically add users to a specific forum when they register for a class.

The function is adding the user to the proper user group (like when I go and look at the usergroup after the code runs, the username is in the proper group).  However, the user is not actually able to access what they should be able to access unless I delete them out of the usergroup and re-add them via the admin Usergroup area.  Is this function missing an important step?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Nov 1, 2011 - 3:17 pm

Not ignoring you. Want to get Steve involved in this one and he should be around later.

andy-signature.png
YELLOW
SWORDFISH
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: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625