Results 1 to 6 of 6

Thread: Expiration by Date

  1. #1
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Expiration by Date

    I'm trying to make the theme expire ads by date rather than after a number of days. It should expire 1 day after the date set in the form. I've turned on ad pruning and set ad_length at '1'.

    I've added a field to the form called Expiration Date (e_date), which seems to be working correctly.

    I've modded the theme's code in form_process.php from this:

    Code:
    $expires = date('m/d/Y G:i:s', strtotime("+" . $ad_length . " days"));
    to this:

    Code:
    $expires = date('m/d/Y', mktime(0,0,0,date('m',$e_date),date('d',$e_date)+$ad_length,date('Y',$e_date)));
    For some reason that code sets the ad expiration to '12/31/1969 19:00:00' regardless of what is entered in the field.

    Any thoughts or ideas how to fix this?

  2. #2
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Expiration by Date

    SUCCESS!

    I hope this helps someone else who may want to set it up this way...

    I replaced the original code in the above post with this:

    Code:
    $expires = date('m/d/Y', mktime(date('m',$event_date),date('d',$event_date)+$ad_length,date('Y',$event_date)));

  3. #3
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Expiration by Date

    Grrrrrr....well, I thought I had this fixed but it appears not. It looks like the code above isn't even what's being used to expire the ads. This code just sets a date on the WP edit page, but the actual pruning functionality is someplace else.

  4. #4
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Expiration by Date

    This is really weird. It appears that if I change the "expires" date in the admin area or in the dashboard edit ad page, it doesn't update the database so it still expires using the first expiration date it calculated?

    Any ideas how to fix?

  5. #5
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Expiration by Date

    Quote Originally Posted by jakesterz
    This is really weird. It appears that if I change the "expires" date in the admin area or in the dashboard edit ad page, it doesn't update the database so it still expires using the first expiration date it calculated?

    Any ideas how to fix?
    Grrrrr...anyone know where the actual code that "expires" the post is? It's NOT the code in form_process.

  6. #6
    Thread Starter
    Senior Member jakesterz's Avatar
    Join Date
    Aug 2009
    Posts
    194
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Expiration by Date

    Well I found it, but I'm not sure what to do with it. It's in the index.php.

    Code:
    $sql = "SELECTIDFROM $wpdb->posts WHEREpost_date<'".date('Y-m-d h:i:s', strtotime("-$prun_period days"))."' ANDpost_status='publish' ANDpost_type='post' LIMIT 10";
    I thought I might be able to just change post_date to e_date and then either delete the part where it subtracts the prun_period or else set it to zero, but it gives me this error.

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
    Any help?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)