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 | |
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 Functionalitys2Member’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
Our New FunctionalityTo 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:
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
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. |