There is nothing in the plugin that will do this. Perhaps if you described what you need this for, we can figure out the best way to do it.
Thread Starter
r0ss26
(@r0ss26)
I have a column in the participants database with the heading “years since PhD completion” and I want this to increment yearly after the user has added their record into the database.
I tried the custom template route and was able to get it do the calculation and display the correct value but then ran into a few problems.
Firstly I need it to work with the multisearch plugin and secondly I need the user to be able to sort by this column. i.e. to sort by increasing or decreasing values in this field.
I feel like the best way to do this would be to update the actual value stored in the database but not sure if this is really the best way or if it’s possible.
-
This reply was modified 6 years, 11 months ago by
r0ss26.
Writing the new value to the database is certainly the way to go here.
Something like this is a bit complex in that it requires the use of a “cron” that will run on a schedule in the background. When it runs, it will check your records and update any that need it.
There are plugins that can make this easier, such as Cronjob Scheduler, but it does require you to write the code that will be executed on schedule.
I have also written a tutorial on setting up cron jobs with Participants Database…it’s for a different purpose, of course, but if you understand the code, it would be easy to use it as a template for your own custom code.
Automatically Sending an Email using the WordPress Cron
Thread Starter
r0ss26
(@r0ss26)
So I’ve downloaded the cronjob scheduler plugin, would a script like the following work if it was run every day?
https://github.com/r0ss26/acuads_wordpress_cronjob/blob/master/cronjobs.php
Looks about right. One possible problem would be the way you’ve set up your conditional, it will only update the record on the one day that is an even multiple of 365 from the day the record was created. If your site gets daily traffic, that probably won’t be an issue, but on a site with low traffic it’s possible the cron won’t run every day, and an update could be missed.