Page 1 of 1
Offering group access
Posted:
September 8th, 2011, 2:56 pm
by holowan
Hi everyone,
Just a quick question today. Our site offers 30+ online learning products, which are all behind S2member pro. Once an individual has subscribed (either monthly or annually), they gain access to all 30+ products.
What we'd like to do is begin offering group access -- which is sometimes called a "site license," meaning that an organization might purchase 50, 100, or 200 "seats." We don't want to be setting up accounts for each individual seat, but rather, we want to set up a single account for the whole organization, limited to the number of seats purchased.
Any suggestions as to how to do something like this with S2 member pro? I dug around quite a bit but came up empty. The only option I'm seeing at this point is to set the "Maximum Unique IP Addresses Allowed" option under "s2Member General Options > Unique IP Access Restrictions" to "Allow infinite IPs" but this causes two problems: 1) it affects individual subscribers accounts (allowing the possibility of username/link sharing), and 2) it's a sitewide setting...it can't be set for specific users (ie: User A is restricted to 75 IPs, User B is restricted to 100 IPs, etc).
Your thoughts would be greatly appreciated!
Geoff
Re: Offering group access
Posted:
September 8th, 2011, 2:58 pm
by Eduan
Maybe you should think about telling the organization about only giving the username and password to a limited amount of users.
Re: Offering group access
Posted:
September 8th, 2011, 3:55 pm
by holowan
Hi Eduan,
Thanks for the reply. That sounds like a pretty simple solution, except that there'd be no security restrictions...both for the organization and for regular subscribers. We could go with the "infinite IPs" option, but that would open things right up security-wise...Any other thoughts?
Re: Offering group access
Posted:
September 9th, 2011, 1:44 am
by Cristián Lávaque
Hi Geoff.
Maybe this video will help you with that:
viewtopic.php?f=36&t=2842
Re: Offering group access
Posted:
September 9th, 2011, 6:27 am
by holowan
Hi Cristián,
Thanks a lot for posting that link -- that was a very interesting set of videos (and it's so amazing to see what S2 is capable of!). That solution was nearly bang on the money for me, but my only concern is that once the Level 1 manager passes out the 50 subscriptions, each user would have to manually create an account (which is fine if we sold a site license to a business).
But what if a school purchased a license and wanted 100 computers in their computer lab to be able to have access. In the above solution, each computer would have to have their own unique account (along with an email address, as required by WordPress). I was hoping we could create just a single account for all 100 computers to use (or 50 computers, or 200 computers, or whatever the case may be). So in other words, a single account for each site license sold. Does that make sense?
Any thoughts?
Geoff
Re: Offering group access
Posted:
September 10th, 2011, 12:58 am
by Cristián Lávaque
Ah, I see your problem. Then you will need to work with the unique IP restrictions, but then you'd be allowing too many IPs to other users...
I don't know if there's a hack that'd allow for different IP limits for different accounts/levels/capabilities. I'll ask Jason.
Re: Offering group access
Posted:
September 10th, 2011, 6:08 am
by holowan
Thanks Cristián, I appreciate you asking Jason about it.
If there were a way to set IP restrictions on a user-by-user basis, perhaps for a different membership level, that would be perfect. Alternatively, I've begun thinking that perhaps the best way to do this would be to set up a completely new install of WP and S2 specifically for this purpose. The problem this raises is having to duplicate all of our learning materials onto the new installation though...and that would be a lot of work.
Thanks again,
Geoff
Re: Offering group access
Posted:
September 13th, 2011, 2:36 am
by Cristián Lávaque
Yeah, I understand what you mean.
Re: Offering group access
Posted:
September 13th, 2011, 2:13 pm
by Jason Caldwell
Thanks for the heads up on this thread.
Yes, this is possible. You could do something like this if you like.
Please create this directory and file:/wp-content/mu-plugins/s2-hacks.php- Code: Select all
<?php
add_action ("ws_plugin__s2member_before_ip_restrictions_ok", "s2_dynamic_ip_controller");
function s2_dynamic_ip_controller ($vars = array ())
{
if (($username = $vars["restriction"]) && is_object ($user = new WP_User ($username)) && isset ($user->ID) && ($user_id = $user->ID))
{
if (c_ws_plugin__s2member_user_access::user_access_level ($user) === 2) {
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "50"; }
else if (c_ws_plugin__s2member_user_access::user_access_level ($user) === 3) {
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "100"; }
}
}
?>
* Please be sure there are no extra spaces/tabs/line breaks before or after the <?php ?> tags.Also, you might need some assistance from a developer to bring this all the way home. The script above is just a way to get you started. In addition, it might be prudent to allow a 50-seat license up to 100 unique IPs, since some people may access the site from both a home and work computer.
Re: Offering group access
Posted:
September 14th, 2011, 5:23 am
by holowan
Hi Jason,
Thank you VERY much for your assistance with this. Admittedly, I'm not very skilled with PHP, but I can read through what you posted and understand what it'll do. Further, I'm a touch nervous to actually attempt to implement it myself (for fear of blowing something up!) -- are you available for custom work like this? Or do you know any developers who might be able to help?
Again, many thanks!
- Geoff
Re: Offering group access
Posted:
September 14th, 2011, 10:17 am
by Jason Caldwell
Thanks Geoff.
Sorry, I'm unavailable for custom work myself, but please check this thread for project assistance:
viewforum.php?f=37
Re: Offering group access
Posted:
October 18th, 2011, 10:13 am
by holowan
Hi All,
First off, a big thank you to everyone on this thread. I've been experimenting with the code that Jason provided for the past few weeks and so far, everything's running very well. However, another issue has come up: Is it possible to restrict users from changing info on the account's profile page? For instance, let's say a school has purchased a "site license" for 100 users. We wouldn't want those 100 users to be able to go into the account and change things like the login password, email address, etc. associated with the account. Is there a way to make Level 2 users, for example, unable to edit profile information?
Again, many thanks for all the help on this one!
Geoff
Re: Offering group access
Posted:
October 20th, 2011, 2:57 pm
by Jason Caldwell
Thanks for the follow-up.First off, I would suggest that you tell s2Member to block all /wp-admin/ areas of your installation.
( this is always a good idea anyway, but in your case, it's very important )Then, if you want to block Profile editing for Members at Level #2,
please create this directory and file:
/wp-content/mu-plugins/s2-disable-profile-mods.php- Code: Select all
<?php
add_action ("init", "disable_s2_profile_mods", 1);
function disable_s2_profile_mods ()
{
if (!empty ($_GET["s2member_profile"]) || !empty ($_POST["ws_plugin__s2member_profile_save"]))
if (current_user_is ("s2member_level2") )
exit ("Profile modifications are not possible for your account.");
}
add_filter ("ws_plugin__s2member_sc_profile", "disable_s2_profile_shortcode");
function disable_s2_profile_shortcode ($code)
{
if (current_user_is ("s2member_level2") )
return false;
return $code;
}
?>
Now, you can work to further prevent this error message from ever being seen by Level #2 Members, by simply NOT introducing a Profile editing panel to them at all. This could be accomplished through the use of Basic and/or Advanced Conditionals documented by s2Member. Please check your Dashboard here:
s2Member -> API Scripting -> Basic/Simple Conditionals.
Re: Offering group access
Posted:
November 8th, 2011, 8:46 am
by xberserker
Jason Caldwell wrote:Thanks for the heads up on this thread.
Yes, this is possible. You could do something like this if you like.
Please create this directory and file:/wp-content/mu-plugins/s2-hacks.php- Code: Select all
<?php
add_action ("ws_plugin__s2member_before_ip_restrictions_ok", "s2_dynamic_ip_controller");
function s2_dynamic_ip_controller ($vars = array ())
{
if (($username = $vars["restriction"]) && is_object ($user = new WP_User ($username)) && isset ($user->ID) && ($user_id = $user->ID))
{
if (c_ws_plugin__s2member_user_access::user_access_level ($user) === 2) {
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "50"; }
else if (c_ws_plugin__s2member_user_access::user_access_level ($user) === 3) {
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "100"; }
}
}
?>
* Please be sure there are no extra spaces/tabs/line breaks before or after the <?php ?> tags.Also, you might need some assistance from a developer to bring this all the way home. The script above is just a way to get you started. In addition, it might be prudent to allow a 50-seat license up to 100 unique IPs, since some people may access the site from both a home and work computer.
This is exactly the code I was looking for. But I would like to have unlimited logins for Subscribers only. Reason being, I have a demo of the item I'm selling. But people keep getting the "503: Service Temporarily Unavailable" message. So would this work?
- Code: Select all
<?php
add_action ("ws_plugin__s2member_before_ip_restrictions_ok", "s2_dynamic_ip_controller");
function s2_dynamic_ip_controller ($vars = array ())
{
if (($username = $vars["restriction"]) && is_object ($user = new WP_User ($username)) && isset ($user->ID) && ($user_id = $user->ID))
{
if (c_ws_plugin__s2member_user_access::user_access_level ($user) === 0) {
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "99999999999999"; }
}
}
?>
Re: Offering group access
Posted:
November 8th, 2011, 5:39 pm
by Jason Caldwell
Please see this thread regarding
demo accounts, and the other code sample that I posted.
viewtopic.php?f=4&t=666&p=46810#p46810( If you still have questions, please DO let us know )
Re: Offering group access
Posted:
November 15th, 2011, 3:01 pm
by holowan
Hi Jason,
Thank you very much for posting your latest round of code. Much appreciated! Unfortunately, I couldn't seem to get it to work. I already have an s2-hacks.php file in the directory you specified, which I created earlier on in this thread when you'd posted your initial code. I simply pasted your latest code directly below the previous code in the s2-hacks.php file (no spaces) and tested it and it didn't block the profile page for a multi-user (Level#2) account. Please note that this sort of coding is not where my skills are, and I literally fumble around until something seems to work, so I could have easily missed something or not followed your instructions quite right. (?)
In any regard, I got looking at the API/Scripting and Conditionals that you'd suggested (as an aside, the more I learn about S2 Member, the more I'm amazed at how powerful it is. Hats off to you for building such an amazing plug-in, sir!), and I did discover a solution. It may be a bit "amateurish" and "hacky" but it seems to work well.
On the membership profile page, I simply put the following:
[s2If current_user_is(s2member_level2)]
Profile modifications are not possible for this account.
[/s2If]
Then below that, I surrounded my original profile page code, including the iframe, etc. with [s2If current_user_is(s2member_level0) OR current_user_is(s2member_level1)] (as we allow free subscribers at Level#0).
As I say, initial testing seems to be working very well, although perhaps because I bypassed your second round of PHP code and went this route, I feel that it might be a bit of an amateur's fix.
Any thoughts on what I've done here?
Once again, many thanks for your help on this thread. Not only have you created an amazing plugin, that seems to just get deeper and deeper the more I learn about it, but your support is incredible too. Thank you!!!
Geoff
Re: Offering group access
Posted:
November 17th, 2011, 11:15 am
by Jason Caldwell
Thanks for the follow-up and kudos!Certainly, those Simple Conditionals should work nicely for you.
I did go back and update the hack that I posted earlier, so you might try it again with the updated details that I posted here:
viewtopic.php?f=36&t=14925&p=48397#p48397