• 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

    (@crowds90)

    No one has figured out the custom field for “How to Expire”: ‘Delete’?

    What is your desired functionality for such a feature?

    Thread Starter crowds90

    (@crowds90)

    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

    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

    (@crowds90)

    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 7 years, 6 months ago by crowds90.

    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.