I have a membership site I wrote from scratch using Types/Views/CRED almost ~5 yearsago. Our membership annual renewals are due for all members in December, as they expire on Dec 31 every year. My client has asked for an easy way to update many expiration dates (year only) at a time, since renewals come in bunches via PayPal. It is otherwise very time consulming to open each member's profile to update that field. There are currently 238 members. I have already done two versions of this, but the one from last December no longer works - and it was never a great solution.
Since I don't believe there is a way to do this using CRED (Toolset forms,) I would like to build a table with all members' name and expiration year, and hopefully use AJAX to execute the update. I am savvy in PHP and MySQL, but not sure which is the best way to approach this. I am simply asking if you guys have any ideas or can point me in the right direction.
If you have members that were created via a Form that uses post expiration then advancing the date when they expire is simply a matter of updating the _cred_post_expiration_time timestamp in the postmeta table.
You can change that in the backend—tedious to do manually for that many members—but you could also run a script to do it.
I don't know how your payments work, but if there is an action you can hook into when a payment is made (e.g. a WC order is completed) then you could automatically update the postmeta for that very post, rather than manually creating a list of posts you want to update the expiration for that you supply to your script.
You got it right on the nose. I am planning to write up a quote for my client to automate the renewal process, using PayPal API and Types API. Unfortunately, I didn't get that all done in time for this year's renewals, which are already coming in now. So, I am trying to throw together something not-so-automatic to get the client through December and January.
I will take a look at the _cred_post_expiration_time timestamp, but I think it's not really what I am looking for at this point. Still, it may be useful in other ways, or eventually.
Thanks for your thoughts! Much appreciated.
And have a good holiday.
I ended up making it work without much trouble (or thinking.)
I set up a View as usual for the CPT I need to access and update, but set the Limit to 1, and added a search box. Then I created a CRED form that is called by the View in the Loop, and it displays the post_title (member name,) the current expiry date, and an "Update" button for submit. As long as I have the Limit set to 1 so that only one record can be submitted at a time, it works.
Not a perfect solution, but it gets the job done and my client is happy. And it's fast.
I am marking this thread as Resolved.
Thanks again for your thoughts and insight. I still plan to figure out the right way to do this function.