Here is what I ended up with: Basically, I had the logic of the timing at the bottom wrong. Figuring out times and dates and what note is hard…
add_action('init', 'delete_unclaimed_apps');
function delete_unclaimed_apps() {
$availapps = get_posts(array(
'post_type' => 'appointment',
'post_status' => 'publish',
'meta_query' => array (
array(
'key' => 'app_status',
'value' => 'available',
),
),
));
foreach ($availapps as $post) {
$timestamp = get_post_meta($post->ID, 'app_timestamp', true);
$now = time() - (7*60*60);
$cutoff = (get_field('minimum_reserve_notice', 'options') * 60 * 60);
if ($now > ($timestamp - $cutoff)) {
wp_trash_post($post->ID);
}
}
}
Related Posts:
- What WordPress function to use to get meta value by using meta keys?
- How to change text color depending on the number value (Using javascript)
- Show metadata in users.php – wordpress
- Ajax call always returns 0
- Is it ok to use a function to output the text domain name in a wordpress theme
- How to override a function when isn’t at functions.php
- Where and how to put inline js in pages
- contactform7 remove tags with “wpcf7_autop false” from functions.php
- How to count number of functions attached to an action hook?
- Show modified time if post is actually modified
- ajax live search for post title
- Hourly Routine Not Firing ( wp_schedule_event() )
- How to get an array of menu items from the toolbar?
- Fatal error: Call to undefined function add_action() – an untouched problem
- echo or print_r in an admin function
- Overriding methods in a child theme
- Automatically Add Specified Value to Attachment Metadata upon Upload
- WP disobeys disabling of the posts revision feature
- Twenty Eleven Child theme error when attempting to use a rewritten function
- Display gallery on top before content
- List of Body Classes Generated by body_class()
- is_dynamic_sidebar always returns true while using Jetpack visibility
- wp_trash_post function to only apply to posts, not pages!
- Redirect specific page in WordPress for first time visit
- Adding widget to dashboard with wp_dashboard_setup not working
- qTranslate in functions.php
- Using Schema with `the_excerpt`
- Image rotation fails to regenerate custom sized thumbnail
- Register and load scripts
- Display alert on successful user Sign Up
- Getting different functions data while using while loop in wordpress
- How to rewrite the custom url in wordpress?
- About cron delete user with meta_key
- Unable to login using username
- How to change the order of Jquery in the footer of my theme?
- Set spesific size of featured images
- Excerpts are not displayed by a shortcode on category pages
- Getting comment count per post not working
- Functions.php Problem
- adding custom script to functions file
- It does not work concatenation in function.php
- edit formatting.php in a theme so it wont get overwritten
- Get arguments from URL
- add_action template_redirect not working for home page
- Way to store featured image width and height in two separate variables?
- Insert template-part inside the content
- Excerpt for pages not showing
- Can’t Write Custom Widget Code In One ECHO
- Got white blank page after copying the functions.php to child theme
- Add unique id to Preview URL
- Numbering lines of code with the tag?
- Latest Foursquare Checkin function
- Insert nofollow in a “Powered By” link, except in the homepage [closed]
- Image loading function not working on archive.php template
- what is best way to keep track of changes made in wordpress website? [closed]
- Is this an acceptable practice for WordPress theme development?
- Add a class to post if it has been recently updated
- how to add_filter to non hook function
- How to change a specific admin label
- WordPress comment processing . Default unapproved comments detection before posting
- Custom image sizes showing in Classic Editor only when upladed directly to post
- Members only function, but allow account activation [solved]
- How to add extra value to permalink
- remove_filter function to unhook twentysixteen parent theme function
- Remove nofollow from internal comment links via functions.php
- Allow logged in user to view a Page, else send to login screen and then redirect back to Page
- Appending „read more” to the excerpt conditionally
- Why is the term of my current page not returning a slug?
- Override plugin function to show invoices even if not logged in
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Serving cache from multiple domain names
- ACF Filter return value
- Fatal error: Call to undefined function. Underscore me
- Why am I losing image quality on my site?
- Replace image attributes for lazyload plugin on image elements with specific class
- Custom shortcode with do_shortcode and substr
- Keep js after reload the page
- Add array of category IDs to global variable?
- How to run a function when publish posts? [duplicate]
- Need some Tweak my nextpage Function
- What is wrong with functions.php? Fills error log with same error
- Function returning queried meta value based on current post ID
- Adding custom field in menu options [duplicate]
- Function the_content
- Edit TinyMCE Button Functionality
- How to add a piece of code in function
- update_usermeta don’t work
- Create html from function
- WP supersize not displaying when different languages flags are selected
- wp_list_pages change of children and anchor of parent
- Admin Panel errors because of functions.php
- WordPress not performing direct update
- Using Output from one Function and calling it into another
- How to add a class and title attribute to the link generated by next/previous post
- “Headers already sent” while trying to add a CSS file to my login page?
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- How do I make my child theme’s CSS update when I save it?
- Bulk set Post Title as Tag where Tag is Empty Function
- Setcookie not setting cookies anywhere except admin
- WooCommerce, change “Add to Cart” to “Link to Product”, only for specific categories