Page 1 of 1

Clearing punished members

PostPosted: August 24th, 2010, 2:30 pm
by Nemrod Kedem
Hi,

Is there a way to list the members that have been punished by the Unique IP Access Restrictions?
Is there a way to reset them so they can get back to work without waiting for the punish to end?
Is there a (future) way to exclude members from being punished?

Thanks,
Nemrod Kedem

Re: Clearing punished members

PostPosted: August 27th, 2010, 2:26 pm
by Jason Caldwell
Hi there. Thanks for the great question.

No, there's not currently a method built into s2Member that can list all punishments.
However, you can use this method to remove punishments early if you like:

Code: Select all
$restriction = strtolower("JohnDoe22");
delete_transient (md5 ("s2member_ip_restrictions_" . $restriction . "_breached"));

$restriction = the Username ( lowercase ).

@TODO :: API function to list all punishments.

Re: Clearing punished members

PostPosted: November 18th, 2010, 11:25 am
by sugeneris
In case votes matter at all, I have a client who's just asked for such a listing.

Re: Clearing punished members

PostPosted: January 18th, 2012, 9:15 am
by foliovision
Hello Jason,

I can see that this thread was created shortly after I posted the same question here: viewtopic.php?f=4&t=14345

When can we expect this list of users who use too many IPs?

Can you at least give us a piece of code which would exclude a single user from these restrictions? Looking at the code, it looks like there is a filter hook called ws_plugin__s2member_disable_all_ip_restrictions which has to return false, otherwise the check will be skipped.

However I could not debug that, as I couldn't get the includes/classes/ip-restrictions.inc.php file to load for my test user.

Any help would be appreciated.

Thanks,
Martin

Re: Clearing punished members

PostPosted: January 18th, 2012, 9:51 am
by foliovision
Hello Jason,

actually here is the code, I'm just not sure if the filter is used at all.

Otherwise it's simple. If user post meta is set, then a function is hooked onto the filter hook, which should exclude user from IP restrictions:

Code: Select all
add_action( 'wp', 'custom_user_exclude_ip_restrictions_check_user' );

function 'custom_user_exclude_ip_restrictions_check_user() {
   $current_user = wp_get_current_user();
   if( is_object($current_user) ) {
      $exclude = get_user_meta( $current_user->ID, 'exclude_ip_restriction', true );

      if( isset($exclude) && $exclude == 'on' ) {
         add_filter( 'ws_plugin__s2member_disable_all_ip_restrictions', 'custom_user_exclude_ip_restrictions_filter' );

      }
   }
}

function custom_user_exclude_ip_restrictions_filter() {

   return true;
}


This is the IF statement I was trying to affect with this (s2member/includes/classes/ip-restrictions.inc.php):
Code: Select all
if (!apply_filters ("ws_plugin__s2member_disable_all_ip_restrictions", false, get_defined_vars ())
                  /* Also allow specific exclusions here. */ && !apply_filters ("ws_plugin__s2member_disable_specific_ip_restriction", false, get_defined_vars ())
                  /* And enabled by site owner? */ && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["max_ip_restriction"] /* And a valid ``$restriction``? */ && $restriction && is_string ($restriction)


I have this code up and running and the site works for me, but it's highly experimental.

Thanks,
Martin