[s2drip] - can you nest? does it work for expired level0 users? can you test with switch user?

I’m having some trouble with the s2drip functionality and I’m not sure what the problem is.

Here’s my code:

[s2If current_user_is(s2member_level0) AND current_user_cannot(access_s2member_ccap_graduate)]

[s2Drip access="level0" from_day="0" to_day="180"]
*content for first 6 months a user without ccap of grad becomes expired*
[/s2Drip]

[s2Drip access="level0" from_day="180"]
*content for after 6 months a user without ccap of grad becomes expired*
[/s2Drip]

[/s2If]

But when I try and test this all I see is post 180 days content. Any thoughts on what I might be doing wrong?

I used user switching to test this for people who were expired just 30 days ago and still I saw the content for post 6 months…

How are you setting how long ago the user had that access? You know that the from_day and to_day are counting since the last time the user got that access, not account registration, right?

I believe s2Drip would work inside s2If, other shortcodes can be nested in it… If you use the s2Drip without the s2If, do you still get the wrong behavior?

I’m not sure if the access checks are working right with the user switching… Maybe try in a different browser session logging into that other account to see if you get the same behavior?

And it made me realize that s2Drip could be improved a bit, adding the possibility to make it check the opposite with a leading exclamation (e.g. !ccap_graduate: should not have that ccap, instead of having it), you wouldn’t need the s2If then.

:slight_smile:

The user automatically gets demoted to level0 after 1 year. I want them to be able to extend their membership (thus show a button for a pro-form) for up to 6 months after they’ve expired. Beyond that, I want them to get in touch with us.

I assumed the counting starts at the time of demotion to level0.

I’ll try checking with an actual user I guess.

And yeah, a leading exclamation within s2drip would be cool. But it’s an easy workaround to add the s2If (as long as it works).

I just tested it the following way with no luck. It just shows the content for after 6 months.

  • set my EOT for 1 minute from now with no grace period for test user
  • logged in as my test user and saw that I still had a membership
  • Waited and refreshed. Saw drip content for after 6 months rather than first 6 months

If you want to send me a PM with access to your test installation, and tell me how to reproduce it, I’ll check it out for you.

  • set my EOT for 1 minute from now with no grace period for test user
  • logged in as my test user and saw that I still had a membership

Had the EOT kicked in? Did you verify that he got demoted before logging in to that account? You can also just remove his access manually from the profile, drop his role to Subscriber (level 0), and then login to his account. If you set the drip for level1, it shouldn’t show for him.

Oh, I think I see now what’s wrong… You wrote s2member_level0, it should be subscriber…

current_user_is(subscriber)

Just in the conditional, because that condition checks for the user role. In the drip it checks the capability, level0 is fine there.

You can remove the role check in the conditional, since you have it in the drip.

I updated the code to have just

current_user_is(subscriber)

But it still isn’t working correctly. The EOT did kick in and the user was demoted. But the user was seeing the drip content for post 6 months, not 0-6 months.

I just sent you a private message…

I replied your message. Did some tests, but noticed something else in the logic for your conditions…

It may not work for you that it checks the the last time the user got access to level0 (i.e. when he registered, instead of when he lost the higher access). s2Drip doesn’t check role changes, it checks access capability changes. The user never loses level0 access.

You’d have to do some custom code…

You’ll need some PHP conditions using the access capability times of the user (the times when he got or lost an s2 access capability)

// Testing
<?php
echo 'Time 180 days ago: ', strtotime('180 days ago'), "\n";
echo 'Current user´s access capability times:', "\n";
$ac_times = get_user_option('s2member_access_cap_times', $user_id);
print_r($ac_times);
?>

You’ll notice if you add a ccap and then remove it from your profile, that the name is prefixed with a dash. So you can look for the times when the user lost the higher level access they had, instead of the time when they got level0.

// Testing
Time 180 days ago: 1553378923
Current user´s access capability times:
Array
(
[1568919357.0001] => level0
[1568919357.0002] => level1
[1568919357.0003] => level2
[1568919357.0004] => level3
[1568919357.0005] => level4
[1568930888.0001] => ccap_testing
[1568930915.0001] => -ccap_testing
)

That’s an admin account, so it doesn’t show loss of level access, but if it were a regular account that had Level 1 and then got demoted to Subscriber (i.e. Level 0), it’d show a -level1 entry. The keys in the array are the timestamp.

:slight_smile:

I suspected that it may have something to do with the Level0 situation. Thanks for taking the time to help me through this!

1 Like