Support Forum
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?
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...
Visit Cruise Talk Central and Mr Papa's World
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!
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...
Visit Cruise Talk Central and Mr Papa's World
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....
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...
Visit Cruise Talk Central and Mr Papa's World
np. glad to help. Thanks for the kind words! good to hear now and then!
Visit Cruise Talk Central and Mr Papa's World
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?
1 Guest(s)