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™
<?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) /* Is Level#2 ( indicating site license for 50 seats ). */
{
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "50"; /* Allow up to 50 unique IP addresses. */
}
else if (c_ws_plugin__s2member_user_access::user_access_level ($user) === 3) /* Is Level#3 ( indicating site license for 100 seats ). */
{
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "100"; /* Allow up to 100 unique IP addresses. */
}
}
}
?>
<?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") /* Disable for Level #2 Members here. */)
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") /* Disable [s2Member-Profile /] Shortcode. */)
return /* Disable for Level #2 Members here. */ false;
return /* Else return Shortcode output by default. */ $code;
}
?>
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* Please be sure there are no extra spaces/tabs/line breaks before or after the <?php ?> tags.
- 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) /* Is Level#2 ( indicating site license for 50 seats ). */
{
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "50"; /* Allow up to 50 unique IP addresses. */
}
else if (c_ws_plugin__s2member_user_access::user_access_level ($user) === 3) /* Is Level#3 ( indicating site license for 100 seats ). */
{
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "100"; /* Allow up to 100 unique IP addresses. */
}
}
}
?>
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.
<?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) /* Is Subscriber */
{
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] = "99999999999999"; /* Allow up to 99999999999 unique IP addresses. */
}
}
}
?>
Return to Common Questions/Problems/Tips
Users browsing this forum: No registered users and 2 guests