Home › Forums › Community Forum › Update EOT for existing (logged in) user
Tagged: EOT, update user
This topic contains 23 replies, has 4 voices. Last updated by eBierek 3 years, 9 months ago.
| Topic Author | Topic |
|---|---|
| Posted: Sunday Mar 10th, 2013 at 7:19 am #44195 | |
|
|
|
|
Hi, I’m using the function below to set EOT for all members, depending on access level. For new users and demoted users (level0) it works fine. But for existing users (logged in and level 1) that renew their membership, EOT is not updated. Everything for the existing user is updated but not the EOT, I can see that in wp-admin. If a user (level 1) has a membership ending 2013-12-31, and they renew, EOT should be updated to 2014-12-31. But it currently stays on 2013-12-31.
Thank you in advance, |
|
List Of Topic Replies
| Author | Replies |
|---|---|
| Author | Replies |
| Posted: Tuesday Mar 12th, 2013 at 11:24 am #44376 | |
|
|
|
|
Hi Emily. If you’re selling with a single payment (buy now), you can let s2Member extend the access for you. [hilite path]Dashboard -› s2Member® -› PayPal® Options -› Automatic EOT Behavior -> Fixed-Term Extensions[/hilite]
Is it being updated at all? You could test adding a unique date (one that would not have been added by your code otherwise) to see if it comes up in the profile, e.g.: [hilite pre_code]$expire_on = "2020-12-31"; [/hilite] By the way, since it’s an extension, I’d first get the EOT time in his profile and then add the year to that. I hope that helps. :) |
|
| Posted: Wednesday Mar 13th, 2013 at 6:41 am #44474 | |
|
|
|
|
Hi Cristián, Thank you for helping. I’m using the pro paypal forms for level #X, one year access. I tried your suggestion with the code below but nothing happens unfortunately.
I also tested the date for new users, setting it to a fixed date of “2020-12-31” but that gives me an EOT of “Thu Jan 01st, 1970”. Why is that?
What could be wrong? Is it
you mean? :) How would I do that if user is level 1-3? |
|
| Posted: Wednesday Mar 13th, 2013 at 11:13 am #44494 | |
|
|
|
|
Ok, I have tested alot and this works, it updates EOT:
But when I add the conditionals for different levels, it doesn’t work. Can’t I use
in s2hacks.php? See first post for reference. |
|
| Posted: Thursday Mar 14th, 2013 at 7:48 am #44593 | |
|
|
|
This returns the right time, 1420002000 (unix time stamp) which is “Wed, 31 Dec 2014 05:00:00 GMT”. What am I missing? :) Unix time stamp is the right format for updating EOT, right? |
|
| Posted: Thursday Mar 14th, 2013 at 11:47 am #44622 | |
|
|
|
Right, I forgot the strtotime in my example. Very sorry about that…
That condition looks fine, just make sure that the account you’re testing with has that role. It works for the other level roles, right? [hilite pre_code] You could also do: [hilite pre_code]$expire_on = strtotime((date('Y') + 1) . '-12-31'); [/hilite] |
|
| Posted: Thursday Mar 14th, 2013 at 12:35 pm #44630 | |
|
|
|
|
Hello again, Setting EOT with conditionals works for new members and demoted members (level0) where EOT is empty. I have tested accounts logged in on level 1-3, no EOT update. But when I do following, without the (current_user_is(“s2member_level2”))-conditionals it works fine:
This is confusing. Is this a bug? |
|
| Posted: Monday Mar 18th, 2013 at 6:36 pm #45079 | |
|
|
|
|
I don’t think it’s a bug. Maybe at that point in the script, the user’s account had not been changed to that role yet and thus the condition isn’t true? Have you tried checking what the user’s role is at that point? Maybe with [hilite mono]S2MEMBER_CURRENT_USER_ACCESS_LEVEL[/hilite]. [hilite path]Dashboard -› s2Member® -› API / Scripting -› PHP/API Constants[/hilite] |
|
| Posted: Tuesday Mar 19th, 2013 at 8:52 am #45164 | |
|
|
|
|
Hello again, Sorry if I confused you. Users account is the same all the time, we don’t have upgrades between levels unless a user is demoted for not paying on time. So the senario is: Level 1 user logs in (I know for sure the level is right), it’s march 2013 (EOT currently set to 2013-12-31). During the month of march all members can renew their membership for upcoming year. When user does that/pays for another year, EOT should be set to 2014-12-31 (get current year and add one). And there is where it all fails, as the new EOT isn’t saved. Payment with PayPal works and is registered, receipt is sent out from PayPal/S2, and Paid Subscr. ID is also updated. What could be missing? |
|
| Posted: Wednesday Mar 20th, 2013 at 6:42 am #45215 | |
|
|
|
|
I don’t know why the condition isn’t working in your hack, if the level role is correct. I guess that if that can’t be made to work, what I’d try would be having a separate function for the modification hook, so you don’t need any condition to know what to do there, you can just extend the EOT. |
|
| Posted: Wednesday Mar 20th, 2013 at 2:30 pm #45244 | |
|
|
|
|
Hi and thank you for trying to help :) I have now two functions as you suggested. One for new members setting EOT to “current year-12-31” and one for members updating their account setting EOT to “(current year+1)-12-31”. This works great! But we also need to handle demoted users. When they decides to finally pay again, their EOT should be set to the same as new users -> “current year-12-31”. Can we handle them with another hook? Right now they get one year too much. Advice much appreciated. |
|
| Posted: Wednesday Mar 20th, 2013 at 9:53 pm #45277 | |
|
|
|
|
Glad that approach worked. :) What you can do is have a condition in that new function, that checks if Level is 0 then this year, else next year. See if that works. |
|
| Posted: Thursday Mar 21st, 2013 at 4:17 am #45308 | |
|
|
|
|
Thanks, I will try that :) |
|
| Posted: Thursday Mar 21st, 2013 at 5:27 am #45314 | |
|
|
|
|
Since a demoted user still is considered to be a “user that will updated” I need to work with these, right?:
That also handles change for other users (level1-3). So I tried following:
This still gives me “current year + one year” even if the user is demoted (level0). Maybe the hooks cant handle conditions? Do you know of others that have tried this? |
|
| Posted: Friday Mar 22nd, 2013 at 5:33 pm #45521 | |
![]() |
|
These hooks can’t use the
|
|
| Posted: Sunday Mar 24th, 2013 at 10:15 am #45587 | |
|
|
|
|
Hi Bruce, thanks for helping :) I have tried this and it still gives me (date(‘Y’) + 1) even if the user is a “subscriber”. Where in the process, is EOT set/updated? Has the user role already changed from “subscriber” to “level1-user” at that time? |
|
| Posted: Tuesday Mar 26th, 2013 at 7:35 pm #45819 | |
![]() |
|
Thanks for the follow-up.
The hooks you’re using are near the end of s2Member’s processes for modifications, after a User has been Modified. If you’re looking for hooks before a User is modified, try these:
|
|
| Posted: Thursday Mar 28th, 2013 at 11:42 am #45979 | |
|
|
|
|
Hi, I’m sorry to say this doesn’t work either.
It still gives me (date(‘Y’) + 1) even if the user is a ‘subscriber’ (demoted). What can I use here? Many thanks. |
|
| Posted: Thursday Mar 28th, 2013 at 12:04 pm #45981 | |
|
|
|
|
This also returns EOT as “todays date + one year”, not “current year+1/12/31” as desired. |
|
| Posted: Thursday Mar 28th, 2013 at 1:12 pm #45985 | |
|
|
|
|
Is there a way I can split these roles up (by hook), just as Cristián suggested for the new users? This should catch existing users when they renew their active account, and sets EOT to current year+1/12/31
This should catch demoted users when they decide to pay, and upgrades from level 0 to 1, and sets EOT to current year/12/31
|
|
| Posted: Sunday Mar 31st, 2013 at 7:31 pm #46218 | |
![]() |
|
Thanks for the follow-up.I’m sorry to say that I can’t really debug this any further for you. I would recommend dumping the variables from your hooks and see if you can find where there is a difference between Users being upgraded and not. If you can’t find any way to distinguish based on what s2Member is passing you, I might suggest just adding a year to the User’s current End of Term if it is already set. That should work equally well, I think. Perhaps something like this:
That’s as far as we can go with custom code. If you need further assistance, we recommend http://jobs.wordpress.net, or another freelance web site where WordPress® experts are offering their expertise through a bid on your project.
|
|
| Posted: Wednesday Apr 3rd, 2013 at 3:57 am #46451 | |
|
|
|
|
Ok, thank you for all the help :) |
|
| Posted: Wednesday Apr 3rd, 2013 at 10:31 am #46468 | |
|
|
|
|
This sounds like exactly what I am after too! eBierek, if you figure out a solution would you mind posting it here? |
|
| Posted: Thursday Apr 4th, 2013 at 2:21 pm #46627 | |
|
|
|
|
@Rick: Sure :) |
|
This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.








Pre-Sale FAQs
Video Tutorials
Community Forum
Knowledge Base
News/Updates
s2 Codex / Docs
GPL v2 License
Contact A Human
About Us
Our Customers
Support Policy
Privacy Policy

