This may take some customizing but I wanted to see if there was a way that cloned items that use the datetime field could automatically be removed on page load or page submission when a particular field has went past a date set.
I am using your extensions to try and create a post scheduling system that uses start and end date/time fields. However, I worry that if they aren’t manually deleted it will get rather confusing and may even end up looking cluttered.
Was wondering if you could point me in the right direction to conditionally wipe out cloned groups after an expire date has passed. Even if this would take any custom scripting outside of what Meta Box supports. I just want to see if this use case would be possible before getting too far down the road with trying to use Meta Box for this feature.
I think you can do that by looping through the meta box definition and remove the fields when a condition happens. The idea is similar to this documentation. Please try it.
Thanks Anh. Been looking into it but struggling to get anything to work.
That’s the setup for the meta box. Basically every field has just a post, start date, and end date. My goal is to allow the user to schedule posts to appear in a featured section and have it remove end dates that have passed and sort by dates as well. Didn’t know how flexible it would be but using Meta Box plugin and extensions really helps to get all the fields put in place. I guess i’m just struggling to gain access to the actual repeater fields that are appearing on the page and there values that are stored.
Then after Feb 6, the post A is removed from the selection (in the admin area)? Is that what you want?
Correct. Basically I am trying to use meta box to create a settings page that allows users to schedule posts that will be featured in 4 featured positions on the homepage. Each position is a separate meta box and within that meta box is a group that contains the post, start date and end date.
My goal would be 3 things.
1.) Order the post entries by start dates.
2.) Delete posts where the current date is past the end date.
Numbers 1 and 2 would make me have to have access to the actual meta values for each repeated group.
I appreciate you helping me with this. Your plugin and extensions are very useful.
I got it. In this case, the problem is handling the “saved meta value”. I’d suggest using WP cron to perform a regular check on the meta value (posts). When a condition occurs (date is passed), then update the meta value.
Thanks. I think that could work. Instead of a cron could I just hook into a certain WordPress action that checks to see if it’s the settings page on each admin page load? That way it’s ordering or deleting them on every page load if needed?
That works but it affects your performance as the action “check-update” runs on every request to your website. This triggers the query to the database. Running only on your settings page reduces the load. But that also means the value is updated only when users visit the settings page, so it’s kind of manual reset.