latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Changing the EOT Demotion Level Dynamically

Home Forums Community Forum Unofficial Extensions/Hacks Changing the EOT Demotion Level Dynamically

This topic contains 2 replies, has 3 voices. Last updated by  Zechariah 4 years ago.

Topic Author Topic
Posted: Wednesday Nov 7th, 2012 at 11:09 pm #30990
Bruce
Username: Bruce
Staff Member

In certain circumstances s2Member’s Automatic EOT system may not be suitable for your specific WordPress® setup. This is especially true when you may be using multiple free levels within s2Member Pro. In these circumstances, you can create a workaround fairly easily with a few lines of code in a mu-plugin.

Existing Functionality

s2Member’s Automatic EOT functionality is included within s2member/includes/classes/auto-eots.inc.php which is the file for s2Member’s class c_ws_plugin__s2member_auto_eots. The functionality that is needed to be changed is within the auto_eot_system() method within this class, specifically at lines 136-137 where $demotion_role and $existing_role are set:

$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber");
$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);

Our New Functionality

To change the functionality outlined below, we want to create a new instance of the class c_ws_plugin__s2member_auto_eots within a Must-Use Plugin/mu-plugin (which is possible due to s2Member’s call to class_exists at line 20). In this case we will call this mu-plugin s2hacks_auto_eots_override.php and put it within wp-content/mu-plugins/ (if you don’t have a mu-plugins folder, you should create it).

Within this file, we’ll want to create an exact copy of s2Member’s class file (s2member/includes/classes/auto-eots.inc.php), and edit lines 136-137:

$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber");
$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);

In this case, I want to edit this functionality so that if a user has reached their EOT date, and they were s2Member Level 2, they should become s2Member Level 1. Otherwise, they should become s2Member Level 0 as usual. Notice that we are using the variable $existing_role, and therefore we must assign this variable’s definition first.

$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);
/**/
if($existing_role === 's2member_level2')
	$demotion_role = 's2member_level1';
else
	$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber");

Now, because Must-Use Plugins are loaded before regular plugins, such as s2Member, this class is overridden, and the functionality outlined above is used instead. To test, you can create a new user at s2Member Level 2, set the EOT date to +10 minutes and then check the user’s Membership Level after the time is up. It should be s2Member Level 1.

And that’s it! Let us know of any issues in the comment section below.

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Tuesday Dec 4th, 2012 at 3:49 am #33418

Hello Bruce,

I have followed the steps, the user is still demoted to subscriber. I even tried to edit s2member/includes/classes/auto-eots.inc.php file directly, also tried restart the apache, the result is still the same.

Did I missed something? Thanks, this tutorial is exactly what I need..

Edit:
OK, sorry, seems I didn’t read it carefully… It works now. Thanks again

Posted: Monday Jan 7th, 2013 at 11:19 am #36465
Zechariah
Username: ctabor1

Bruce…
This is not exactly my issue or topic, but close enough and part of this is necessary…
I see you’ve done alot of learning and research for S2 Payment Stuff… and I think our site has some minor incorrect settings that are giving us an invalid message for unsubscribe.

There is a story behind it that I am guessing is the cause… or part of it… but don’t want to post it here in its entirety… I can share another post and conversation I had with Cristián… if that will help.

Is it possible for a pm?
I am hoping to find someone to troubleshoot this… you are someone you can send me to…I am not sure where to go to find someone knowledgeable that I can pay to troubleshoot and fix this.

I think we are close but something is awry and needs to be remedied…

  • First, with our Beta Group (they signed up via Standard paypal – so need to be moved over to PayPal Pro somehow… and I saw instructions but not sure how to do this… )
  • Second… for the MAIN launch and new registrants we used PayPal Pro… (FYI, in a post I saw mention of ERP and NOT to use that? but thought I was told we needed to sign up for a monthly upgrade with PayFlow to do monthly recurring… and again, not sure if that is same thing or not… obviously, I find it VERY confusing)… When someone tries to unsubscribe from this group, they get an invalid unsubscribe message.

So, I think that is where the disconnects might be.

Here is my direct email… ctabor1 at bestmail.us
I am a paid member, but not a developer and truly need someone to sort this out for my client.

Hope to hear from you.
Christine

P.S. I can supply all the credentials needed to troubleshoot, as necessary. Thanks…

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.