Viewing 6 replies - 1 through 6 (of 6 total)
  • I am also interested in this question, is there any quick solution for it?

    im also interested in this

    I’ve trying to add an epoch value to _expiration-date,
    this string ‘s:52:”a:2:{s:10:”expireType”;s:5:”draft”;s:2:”id”;i:3932;}”;’ for _expiration-date-options and ‘saved’ at _expiration-date-status

    note that the string hast the post id, so that’s not OK for all posts, you have to replace that

    this is still not working ??

    for example:
    the value stored in _expiration-date post meta field is: 1464270120000
    which is GMT: Thu, 26 May 2016 13:42:00 GMT

    but when I check on the plugin box, it shows the post expires on Nov. 15th 2016 at 17:00.

    very weird

    well I got it to work guys, I was very close
    here it goes:

    the time stamp should be in seconds, not miliseconds
    so trim the last three characters of it

    in a previous comment I had this timestamp: 1464270120000
    but the correct one was 1464270120

    ??

    now, while you have the plugin installed, you can use this function:
    _scheduleExpiratorEvent($post_id,$ts,$opts);

    in case you want to see it’s code, head to the file post-expirator.php file on the root of the plugin directory.

    last but not least, $opts, should be an array, in my case I formatted it like this:
    $opts = array();
    $opts[‘expireType’] = ‘draft’;
    $opts[‘id’] = $post_id;

    and that should do it!

    Hi @kilinkis. Thanks for sharing. I’m using WP All Import and can import the right date using the Unix timestamp as you describe. However, they don’t expire (everything is working when I add a post manually they expire then, just not if I add posts by importing).

    I think this is because there’s nothing in the _expiration-date-options field. I’m not sure how to import this when it’s in the a:2:{s:10:”expireType”;s:5:”draft”;s:2:”id”;i:12345;} format because I don’t know what the id will be at the time of importing.

    Do you know what would be the best way around this? I’m fairly new to this so working things out as I go along but this one is baffling me.

    Do I need to edit the code in the plugin? I can see the following in there:

    $opts = array();
    $ts = get_gmt_from_date(“$year-$month-$day $hour:$minute:0”,’U’);

    // Schedule/Update Expiration
    $opts[‘expireType’] = $_POST[‘expirationdate_expiretype’];
    $opts[‘id’] = $id;

    I can also see function _scheduleExpiratorEvent($id,$ts,$opts) a little further down.

    I presume I would change the code that you mentioned in the Schedule/Update Expiration section? If this is the case, do you know what I would need to put under the _expiration-date-options column when I’m importing? Anything at all or would this be catered for automatically with the edited code?

    Many thanks in advance to anyone that can help.

    jattard

    (@jattard)

    Hi @hs1972,

    I am using wp all import too and I have your same issue. Have you managed to find a solution?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add expiration date programmatically’ is closed to new replies.