Title: Custom Fields and Timeout
Last modified: May 4, 2017

---

# Custom Fields and Timeout

 *  [crowds90](https://wordpress.org/support/users/crowds90/)
 * (@crowds90)
 * [9 years ago](https://wordpress.org/support/topic/custom-fields-and-timeout/)
 * Hi,
 * I am using this plugin for when I import products. What is custom field to enable
   post expiration checkbox, date, and “How to expire” to delete?
 * Also if I have the same date and time for 1000s of products will the script timeout
   or malfunction, or will it run smoothy. Thanks

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

 *  Thread Starter [crowds90](https://wordpress.org/support/users/crowds90/)
 * (@crowds90)
 * [9 years ago](https://wordpress.org/support/topic/custom-fields-and-timeout/#post-9106234)
 * No one has figured out the custom field for “How to Expire”: ‘Delete’?
 *  [Aaron Axelsen](https://wordpress.org/support/users/axelseaa/)
 * (@axelseaa)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-and-timeout/#post-9171938)
 * What is your desired functionality for such a feature?
 *  Thread Starter [crowds90](https://wordpress.org/support/users/crowds90/)
 * (@crowds90)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-and-timeout/#post-9178323)
 * Hi Aaron,
 * Thanks for getting back on the support forum. I noticed you updated the plugin.
   I am having an issue though. I import using the custom fields of “_expiration-
   date-status > saved” and “_expiration-date > 1496112420”. So it imports properly
   but it won’t actually delete/draft after the expiration time. This seems to be
   a problem with the cron which is what people seem to say. How to fix this? Thanks
 *  [Aaron Axelsen](https://wordpress.org/support/users/axelseaa/)
 * (@axelseaa)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-and-timeout/#post-9178343)
 * You can’t just add the meta data – that does not actually set the cron events.
   With your import process, you’ll need to run the “_scheduleExpiratorEvent($id,
   $ts,$opts)” function which will solve your problem.
 * You will need to manually build the “opts” array – easiest way may be to just
   copy it from a different post for what you want, and then just update the post
   id.
 * Hope that helps.
 *  Thread Starter [crowds90](https://wordpress.org/support/users/crowds90/)
 * (@crowds90)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-and-timeout/#post-9178540)
 * Sorry I am not very skilled with this stuff. How do I run the “_scheduleExpiratorEvent(
   $id,$ts,$opts)” or build the “opts” array?
 * In another post someone seemed to get this code working with WP All Import plugin:
 *     ```
       add_action('pmxi_saved_post', 'post_saved', 10, 1);
   
       function post_saved($id) {
          $expiration_date = get_post_meta($id, 'expiration-date', true);
          if ($expiration_date) {
             $opts = array();
             $opts['expireType'] = 'delete';
             $opts['id']         = $id;
             echo "Setting expiration date for post " . $id . " to the timestamp " . $expiration_date;
             _scheduleExpiratorEvent( $id, $expiration_date, $opts );
          } else {
             echo "No expiration date set for post " . $id . ". Exiting";
          }
       }
       ```
   
 * The problem is `add_action('pmxi_saved_post', 'post_saved', 10, 1);` is part 
   of WP All Import and I am using Woocommerce CSV Importer. Is it possible to get
   this to work without that part? Let me know. Thanks
    -  This reply was modified 8 years, 11 months ago by [crowds90](https://wordpress.org/support/users/crowds90/).
 *  [Aaron Axelsen](https://wordpress.org/support/users/axelseaa/)
 * (@axelseaa)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-and-timeout/#post-9180167)
 * Wherever you are trying to currently update the meta, just replace that code 
   with a variation of this:
 *     ```
          $expiration_date = get_post_meta($id, '_expiration-date', true);
          if ($expiration_date) {
             $opts = array();
             $opts['expireType'] = 'delete';
             $opts['id']         = $id;
             echo "Setting expiration date for post " . $id . " to the timestamp " . $expiration_date;
             _scheduleExpiratorEvent( $id, $expiration_date, $opts );
          } else {
             echo "No expiration date set for post " . $id . ". Exiting";
          }
       ```
   

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

The topic ‘Custom Fields and Timeout’ 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/)

 * 6 replies
 * 2 participants
 * Last reply from: [Aaron Axelsen](https://wordpress.org/support/users/axelseaa/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-and-timeout/#post-9180167)
 * Status: not resolved