I suggest you ...

Date expire

published using wp date picker (whatever date) expire post Automatically one day after date and remove post to draft,private,trash,delete etc

6 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Anonymous shared this idea  ·   ·  Admin →

    3 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • IrnHide ChuckIrnHide Chuck commented  · 

        I went back and looked further into what you were talking about... it appears you are referencing the default Date/Time Duration.
        Again, doesn't make sense to set a default off of a datepicker date. That would have you selecting a Date/Time to expire at post creation. Which in turn would expire so many days after that Picker date. Why not just enter the exact Date/Time to expire in the first place?

      • IrnHide ChuckIrnHide Chuck commented  · 

        I'm not sure what you're looking at. The expiration time is set as a Date / Time - not X number of days after the post.

      • Anonymous commented  · 

        Love your plug-in but!
        Can this plug-in be change to run not from (published date) but from jquery datepicker date ,then i can put a custom date echo strtotime("+1 day"), "\n"; to expire .Really need this .i have a plug-in made but doesn't send to draft etc wonder if any of the code could help with this on your plug-in to have this implemented ,this works 23 hours after event date from jquery datepicker .

        // create a scheduled event (if it does not exist already)
        function cronstarter_activation() {
        if( !wp_next_scheduled( 'mycronjob' ) ) {
        wp_schedule_event( time(), 'everyminute', 'mycronjob' );
        }
        }
        // and make sure it's called whenever WordPress loads
        add_action('wp', 'cronstarter_activation');

        // here's the function we'd like to call with our cron job
        function my_repeat_function() {

        // do stuff

        global $wpdb;

        $jh_date = date("Y-m-d", strtotime('-23 hours'));

        $jh_query = "SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key = 'sale_date' AND meta_value < '$jh_date'";

        $results = $wpdb->get_results($jh_query);

        foreach($results as $post){

        // Let the WordPress API do the heavy lifting for cleaning up entire post trails
        wp_delete_post($post->post_id, false);
        wp_mail(
        'email address',
        ' Post Deletion',
        'The following Post id was just deleted: ' . $post->post_id
        );

        wp_mail(
        'email address',
        ' Post Deletion',
        'The following Post Title was just deleted: ' . get_the_title($post->post_id)
        );


        }
        }

        // hook that function onto our scheduled event:
        add_action ('mycronjob', 'my_repeat_function');

        // unschedule event upon plugin deactivation
        function cronstarter_deactivate() {
        // find out when the last event was scheduled
        $timestamp = wp_next_scheduled ('mycronjob');
        // unschedule previous event if any
        wp_unschedule_event ($timestamp, 'mycronjob');
        }
        register_deactivation_hook (__FILE__, 'cronstarter_deactivate');

        // add custom interval
        function cron_add_minute( $schedules ) {
        // Adds once every minute to the existing schedules.
        $schedules['everyminute'] = array(
        'interval' => 60,
        'display' => __( 'Once Every Minute' )
        );
        return $schedules;
        }
        add_filter( 'cron_schedules', 'cron_add_minute' );

        ?>

      Feedback and Knowledge Base