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.

Problem: Changing the EOT Demotion Level Dyna

Home Forums Community Forum Problem: Changing the EOT Demotion Level Dyna

This topic contains 9 replies, has 2 voices. Last updated by  Cristián Lávaque 3 years, 8 months ago.

Topic Author Topic
Posted: Thursday Apr 11th, 2013 at 3:58 pm #47223

Hi,

I want to change the user role upon EOT end to s2member_level1. I found this article in your forum http://www.s2member.com/forums/topic/changing-the-eot-demotion-level-dynamically/ but it doesn’t seem to work for me.

I created an exact copy of s2member/includes/classes/auto-eots.inc.php, put it in mu-plugins and renamed it

wp-content/mu-plugins/s2hacks_auto_eots_override.php

Then I deleted

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

to

$existing_role = c_ws_plugin__s2member_user_access::user_access_role($user);   

if($existing_role === 's2member_level2' || $existing_role === 's2member_level3')          

$demotion_role = 's2member_level1';

else

$demotion_role = c_ws_plugin__s2member_option_forces::force_demotion_role("subscriber");

But it doesn’t work for me. It just stays at the initial user level set for the user. When I var_dump the

get_user_meta($User_ID, 'core_capabilities', true);

I still get the initial user level. In the wp backend user settings it is of course also the same.

I tried to use just one user level in the if statement instead of to with the or (||), there it works. But if I try to combine both user levels, either with an elseif statement or just two simple if statements after each other, only one gets the correct user level, the second stays with the initial one.

So I guess my main question is, how can I combine both user levels in the if statement.

Do you have any idea where the problem might be?

And another problem I found is, that the date timestamp of the registration is saved after UTC 0 and the EOT time is calculated accordingly to that value. But here in Germany we have +2 hours (normally just +1hour, but now in the summertime timezone its +2). When I look in the user overview of the wp backend, the registration time is shown correctly like the registration time was here in Germany at that moment. But I guess the EOT time doesn’t take this into account, so in total the registered user looses, in that case 2 hours of his payed for time.

I’m basing my assumption on the timestamp saved in core_s2member_auto_eot_time. Or is there a function in your plugin that takes this into account and gives the user the correct EOT time?

I stumbled upon this problem while writing a function that shows the user how much time he has left until his subscription is running out.

I would appreciate if you could clarify this issue for me.

Thank you very much for your efforts!

Best regards from Berlin

List Of Topic Replies

Viewing 9 replies - 1 through 9 (of 9 total)
Author Replies
Author Replies
Posted: Friday Apr 12th, 2013 at 7:12 am #47290

So if the user is level 2 or 3, he should be demoted to 1, but if 1 demoted to 0 (subscriber)? Maybe something like this:

Create this directory and file: /wp-content/mu-plugins/s2hacks.php
[hilite pre_code]
Knowledge Base » Hacking s2Member® Via Hooks/Filters
Knowledge Base » Forcing A Specific Demotion Role

Posted: Friday Apr 12th, 2013 at 8:19 am #47303

Hi Cristián,

thank you for your answer, but it doesn’t work for me. I deleted my s2hacks_auto_eots_override.php and inserted your code into my s2hacks.php, but the users still get demoted to subscriber, no matter which level they are as default.

Here is what I pasted in:

add_filter("ws_plugin__s2member_force_demotion_role", "my_demotion_role");
function my_demotion_role($role = 'subscriber') {
    	if (current_user_is('s2member_level3') || current_user_is('s2member_level2')) {
            	$role = 's2member_level1';
        }
	return $role;
}

Do you have another idea?

Thank you!

Posted: Friday Apr 12th, 2013 at 2:37 pm #47320

Ok, I seem to have solved the issue. Somehow the if statement with the or operator doesn’t work. I experienced the same issue with my first attempt. My solution now is:

add_filter("ws_plugin__s2member_force_demotion_role", "my_demotion_role");
function my_demotion_role($role = 'subscriber') {
        $role = 's2member_level1';
	return $role;
}

And could you please comment on my second question in my first post? Thank you!

And another problem I found is, that the date timestamp of the registration is saved after UTC 0 and the EOT time is calculated accordingly to that value. But here in Germany we have +2 hours (normally just +1hour, but now in the summertime timezone its +2). When I look in the user overview of the wp backend, the registration time is shown correctly like the registration time was here in Germany at that moment. But I guess the EOT time doesn’t take this into account, so in total the registered user looses, in that case 2 hours of his payed for time.

I’m basing my assumption on the timestamp saved in core_s2member_auto_eot_time. Or is there a function in your plugin that takes this into account and gives the user the correct EOT time?

Best Regards

Posted: Sunday Apr 14th, 2013 at 6:56 am #47444

Ok, I seem to have solved the issue. Somehow the if statement with the or operator doesn’t work. I experienced the same issue with my first attempt. My solution now is:

That’ll demote everyone to Level 1, even Level 1 users.

And could you please comment on my second question in my first post? Thank you!

I think s2Member uses UTC to set the EOT. If you need to modify it, you could probably use the grace time setting. [hilite path]Dashboard -› s2Member® -› PayPal® Options -› Automatic EOT Behavior -> EOT Grace Time[/hilite]

Posted: Sunday Apr 14th, 2013 at 7:05 am #47445

Thank you for your answer!

That’ll demote everyone to Level 1, even Level 1 users.

Yes, I know that. But meanwhile I changed the concept, so that demoting to subscriber is ok.

I think s2Member uses UTC to set the EOT. If you need to modify it, you could probably use the grace time setting. Dashboard -› s2Member® -› PayPal® Options -› Automatic EOT Behavior -> EOT Grace Time

Ok, I will look into it and see what the best solution might be for me.

Meanwhile I tried to use this hack:

http://www.s2member.com/kb/auto-login-upon-registration/

But it doesn’t work for me. Do I have to make additional settings in the s2member Backend?

I also don’t use a custom success shortcode, so at the moment I don’t see where the problem might be..

Here is an example shortcode I use:

[s2Member-Pro-PayPal-Form level="2" ccaps="" desc="Komfort Zugang für ein Jahr 45 € (zzgl. 19% Ust. -> 53,55 €)" ps="paypal" lc="" cc="EUR" dg="0" ns="1" custom="www.example.de" ta="0" tp="0" tt="D" ra="45" rp="1" rt="Y" rr="0" rrt="" rra="2" accept="paypal,visa,mastercard" accept_via_paypal="paypal" coupon="" accept_coupons="0" default_country_code="DE" lang="de_DE" captcha="0" /]

Thank you again! Have a nice and sunny sunday.

Posted: Sunday Apr 14th, 2013 at 7:10 am #47446

But it doesn’t work for me. Do I have to make additional settings in the s2member Backend?

No, it should work with just that.

Maybe there’s a plugin in your installation interfering with that hack? I guess you could try the troubleshooting tips here: Knowledge Base » Common Troubleshooting Tips

Posted: Sunday Apr 14th, 2013 at 7:25 am #47447

Yes, it works to a certain extend. After successful registration I am forwarded back to the form I just filled out. When I make the next click, the user is automatically logged in.

Is there any way that I can define the site to which the user should be forwarded at that point, so that he doesn’t come back to the form he just filled out?

Thank you!

Posted: Sunday Apr 14th, 2013 at 7:44 am #47448

Oh, never mind please. I found the solution myself, didn’t use the success=”” tag until now. Sorry and thank you!!

Posted: Sunday Apr 14th, 2013 at 8:27 am #47450

No problem. Glad you sorted it out. :)

Viewing 9 replies - 1 through 9 (of 9 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.