Title: Programmatically setting draft date not working
Last modified: March 19, 2024

---

# Programmatically setting draft date not working

 *  Resolved [buzzboldjeremy](https://wordpress.org/support/users/buzzboldjeremy/)
 * (@buzzboldjeremy)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programmatically-setting-draft-date-not-working/)
 * I’m using version 3.3.0 of PublishPress Future. I’m trying to programmatically
   set a post to draft when a post is created or updated, but no matter what date
   is set it seems to default to 7 days after the post published date. Do you know
   what I’m doing wrong?
 *     ```wp-block-code
       function update_post_expiration($post_id, $post_after, $post_before)
       {
   
               $application_deadline = get_post_meta( $post_id, 'application_deadline', true );
   
               $timestamp = strtotime( str_replace('-', '',$application_deadline) );
               $timestamp = strtotime('+1 day',$timestamp);
               $timestamp--;
   
               if (defined('PUBLISHPRESS_FUTURE_LOADED')) {
                       do_action('publishpressfuture_unschedule_expiration', $post_id);
                       $options   = [
                               'expireType' => 'draft',
                               'id'         => $post_id,
                       ];
                       do_action(
                               'publishpressfuture_schedule_expiration',
                               $post_id,
                               $timestamp,
                               $options
                       );
               }
   
       }
       add_action('post_updated', 'update_post_expiration', 10, 3);
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Steve Burge](https://wordpress.org/support/users/stevejburge/)
 * (@stevejburge)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programmatically-setting-draft-date-not-working/#post-17512419)
 * Hi [@buzzboldjeremy](https://wordpress.org/support/users/buzzboldjeremy/). Thanks
   for using PublishPress Future.
 * Sorry, we don’t provide support for custom code here on the WordPress forums.
   We do offer that for Pro members at PublishPress.com.
 * There is a guide available here to show how to add actions programmatically: 
   [https://publishpress.com/knowledge-base/programmatically-schedule-actions/](https://publishpress.com/knowledge-base/programmatically-schedule-actions/)
 *  Thread Starter [buzzboldjeremy](https://wordpress.org/support/users/buzzboldjeremy/)
 * (@buzzboldjeremy)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programmatically-setting-draft-date-not-working/#post-17515277)
 * Is there a way to turn off the 7 day default expiration?
 *  Thread Starter [buzzboldjeremy](https://wordpress.org/support/users/buzzboldjeremy/)
 * (@buzzboldjeremy)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/programmatically-setting-draft-date-not-working/#post-17515599)
 * Thank you, you can close this

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Programmatically setting draft date not working’ is closed to new replies.

 * ![](https://ps.w.org/post-expirator/assets/icon-256x256.png?rev=3118683)
 * [Schedule Post Changes With PublishPress Future: Unpublish, Delete, Change Status, Trash, Change Categories](https://wordpress.org/plugins/post-expirator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-expirator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-expirator/)
 * [Active Topics](https://wordpress.org/support/plugin/post-expirator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-expirator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-expirator/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [buzzboldjeremy](https://wordpress.org/support/users/buzzboldjeremy/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/programmatically-setting-draft-date-not-working/#post-17515599)
 * Status: resolved