PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

IP restriction question...

s2Member Plugin. A Membership plugin for WordPress®.

IP restriction question...

Postby solraco » July 25th, 2011, 12:02 pm

Is there any way to target certain account levels for different IP restrictions...

For example if I had a level 1 account restricted to 2 IPs and then had a level 2 account that was restricted to 10 IPs?

Is there any way to do this with s2member?

Thanks for the help in advanced.
User avatar
solraco
Registered User
Registered User
 
Posts: 4
Joined: July 15, 2011

Re: IP restriction question...

Postby Cristián Lávaque » July 26th, 2011, 2:12 am

s2Member doesn't have that yet, but you may be able to hack it in.

Here's a related thread viewtopic.php?f=4&t=2839#p9484

Take the hack Jason posted and edit it to work for you. Here's the line where that hook is in the IP Restrictions file. viewtopic.php?f=40&t=13016&src_doc_v=110710#src_doc_line_45

Based on the level of the current user, you could edit the number of IPs changing $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] in your hack.

/wp-content/mu-plugins/s2hacks.php
Code: Select all
<?php
add_action 
('ws_plugin__s2member_before_ip_restrictions_ok', 'levels_max_ips');
function levels_max_ips($vars = array()) {
    if (is_object($user = new WP_User($username = $vars['restriction'])))
        if ($user->has_cap('s2member_level1'))
            $GLOBALS['WS_PLUGIN__']['s2member']['o']['max_ip_restriction'] = 2;
        if ($user->has_cap('s2member_level2'))
            $GLOBALS['WS_PLUGIN__']['s2member']['o']['max_ip_restriction'] = 10;
}
?>


Haven't tried it. Let me know if that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: IP restriction question...

Postby solraco » July 26th, 2011, 4:28 pm

Hi Cris.

That worked perfectly.

Thank you so much for your help.

Do you know if this functionality will be added to a future release?

Thanks again!
User avatar
solraco
Registered User
Registered User
 
Posts: 4
Joined: July 15, 2011

Re: IP restriction question...

Postby Cristián Lávaque » July 27th, 2011, 1:55 am

Awesome! Thanks for the update. :)

I imagine it may at some point, no date at this moment, though. Still, this hack will remain after updates, so it's safe to use for now.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 0 guests

cron