Hi @leinad4mind,
Thank you for using Paid Memberships Pro. This code looks correct.
We are able to help troubleshoot why it’s not working. Please can you open a support thread on https://www.paidmembershipspro.com
Here is documentation revolving around this – https://www.paidmembershipspro.com/change-membership-level-on-cancellation-or-expiration/
The code you are using is if you have setup your membership to have tiered (higher and lower levels).
I hope this helps.
The user level IDs are 3 and when it expire it needs to go to 5 not to expire.
Is this code only for cancellation or it should work too for expiration?
I can’t see nothing in the link provided…
-
This reply was modified 5 years, 9 months ago by
Leinad4Mind.
-
This reply was modified 5 years, 9 months ago by
Leinad4Mind.
This code should work for both expiration and cancellation.
I have taken a look at the link and you will need an account to access the content.
Ive an account.
I saw that there was an update on the gist. Anyway, this still should work but it doesn’t.
-
This reply was modified 5 years, 9 months ago by
Leinad4Mind.
Thanks for this, if you have an account on paidmembershipspro.com please can you open a support thread on there so we may troubleshoot your code.
I can’t go to the Support Forum, I would need to buy a plan. I don’t need a plan for this, at least for now. If the free plugin doesn’t work at all and is full of bugs why should I buy it?
This code was provided in the past here. But the code doesn’t work… I guess I’ll need to edit core files.
I do not recommend editing core files as once you update your custom code will be overwritten.
You mentioned that Paid Memberships Pro is full of bugs, would you mind pointing these out to me so I may add this to our development schedule so we may fix these bugs as soon as possible?
Also I have done another once-over on your code to see what could be causing this not to work, please try the following code – https://gist.github.com/strangerstudios/5703500#file-pmpro_cancelled_level-php
This code will not run if there is a next payment date for the particular user, such as a recurring subscription. This will assign a user to a particular level when they cancel, regardless of the level they are canceling. Would this work for you?
I do highly recommend in getting a premium account so you may get higher more technical support than what we offer on our .org forums and help troubleshoot your custom code, such as this thread’s query.
The code gist above should solve your problem, I have tested it on my local environment and it works as intended.
Please let me know about the bugs you are facing so I may attend to these with high priority.
-
This reply was modified 5 years, 9 months ago by
Andrew Lima.
Thanks. I’ll do some tests. One last doubt, how can I simulate this without waiting a full day to pass?
What you will need to do is create a member and backdate their expiration date.
You then can run the expiration code by going to https://yourwebsite.com/wp-content/plugins/paid-memberships-pro/scheduled/expirememberships.php
in your browser.
This will manually run and expire the user’s membership.
Strange because I run that and I get a blank page and nothing happens.
I was sleeping yesterday -.- I put the wrong year LOOL
Thanks! That helped!
PS:
//if we see this global set, then another gist is planning to give the user their level back
global $pmpro_next_payment_timestamp;
if(!empty($pmpro_next_payment_timestamp))
return;
Can you tell me what does this code really do? Just to be sure I need it in my code or not.
-
This reply was modified 5 years, 9 months ago by
Leinad4Mind.
Hi there, I need to reopen this, I’ve more information about the bug.
See this image please:
https://i.imgur.com/3ygiGea.png
I had 4 users that were moved to the cancel group.
This is my settings: https://i.imgur.com/lonO3uK.png
When they renew the end date should be 1 year later and not the end of the current year!
This user was moved to cancel group instead Free Member: https://i.imgur.com/B8itY12.png
As we can see it have been put on Free member but the end date was not changed to Never 🙁
So I beleive that the date is causing the issue, since maybe after the date ends the users is moved to cancel group.
About the 4 users that renew, they all have the same thing in common, they all were still on an membership plan when they renew. I’ve others users that renew after the membership plan expired, and it was all good with their account.
So there is some bug when users renew when still on a valid membership. It should change the end date.
Thank you for your patience regarding this.
Are you running any custom code that will alter the expiration date such as to only cancel the user’s account on their next payment date and not immediately?
Please let me know.