Change date when post expires

Closed
REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme REHub - Price Comparison, Affiliate Marketing, Multi Vendor Store, Community Theme September 01, 2024
Login to reply
Chanchal Rani
2 hours ago

We invite you to explore hidden desires with absolute discretion. Escorts In Kapashera from our agency are celebrated for their elegance and adventurous spirits. They are ready to accompany you on spontaneous journeys, whether exploring the city's nightlife or enjoying a quiet, intimate evening filled with genuine warmth.

Michael Rigney
1 month ago

Shipixy is a trusted international shipping platform that makes sending packages across the globe simple, affordable, and efficient. Whether you're an eCommerce business, a small company, or an individual shipper, Shipixy helps you access competitive shipping rates, create shipping labels, track shipments in real time, and manage deliveries from one easy-to-use platform. With reliable shipping solutions, worldwide coverage, and a commitment to fast, secure service, Shipixy helps businesses and customers streamline their international shipping experience with confidence.

Raghav Roy
1 month ago

An engaging post with logically presented ideas and smooth transitions. It enhances readability and makes understanding easier. While exploring Delhi Call Girls your content was insightful and well-organized.

Taylor Scott
1 month ago

Fixing these frustrating backend system errors is exhausting, so I am taking a break to read up on finding a qualified schema therapist london.

nehal karkera
1 month ago

 you'll need to master every corner to unlock the best rides. MyMilestoneCard card portal

geometry dash
3 months ago

To drift around turns without falling off the track is Drift Boss' mission. Sounds easy, right? As you progress, it gets harder. Soon, you'll need to master every corner to unlock the best rides.

Divya Rawat
3 months ago
Kavya Mehra embodies the kind of escort that every man envisions. Those who spend time with Kavya Mehra once enjoy being with her repeatedly. This is mainly due to the happiness that Kavya Mehra brings to her clients. They find joy from inside themselves Panchsheel Park Escorts || Escorts in Patel Nagar || Pitampura Escorts Service || Escorts Service Preet Vihar || Escorts Service in Jangpura
IO Skribbl
3 months ago

Your website has provided us with information that is helpful for the objective that we are pursuing. Several very good suggestions can be found in your post Skribbl IO.

Allen Barry
3 months ago

It's a world away from just trying to steal a brainrot calculator for quick game stats during a coffee break, isn't it? The persistence here is methodical.

Bioinformatics India commented privately
Bioinformatics India
1 year ago

Love you so much :) 

Igor Sunz Support Agent
1 year ago
add_action('post_change_expired', 'cpt_expired_function', 11, 1);
function cpt_expired_function($expired=''){
global $post;
if (isset($post)){
   $post_id = $post->ID;
}else{
   return false;
}
$expired_exist = get_post_meta($post_id, 're_post_expired', true);
if($expired_exist == 1){
   $new_date = '2020-01-01 00:00:00';
   $postarr = array(
      'ID' => $post_id,
      'post_date' => $new_date,
      'post_date_gmt' => get_gmt_from_date($new_date)
   );
   wp_update_post($postarr);
}
}
Bioinformatics India
1 year ago

Support renewed to get this one resolved, Please update.

Bioinformatics India
1 year ago

Hi Igor, Can you help me with a code where when the coupon code expires, the date of that post is automatically set to some date in 2019?

I tried the below code, but it is not working

add_action('post_change_expired', 'post_change_expired_function', 10, 1);

if (!function_exists('post_change_expired_function')) {

    function post_change_expired_function($expired=''){

        global $post;

        if (isset($post)){

            $post_id = $post->ID;

        }

        else{

            return false; // Error: no POST ID

        }

        $expired_exist = get_post_meta($post_id, 're_post_expired', true);

        if($expired == 1 && $expired_exist != 1){

            update_post_meta($post_id, 're_post_expired', 1);

            wp_set_object_terms($post_id, 'yes', 'offerexpiration', false );

            // Set the post date to January 1, 2020

            $new_date = '2020-01-01 00:00:00';

            $postarr = array(

                'ID' => $post_id,

                'post_date' => $new_date,

                'post_date_gmt' => get_gmt_from_date($new_date)

            );

            wp_update_post($postarr);

        } elseif($expired == 'no'){

            update_post_meta($post_id, 're_post_expired', 0);

            wp_set_object_terms($post_id, NULL, 'offerexpiration', false );

        } elseif($expired_exist == 0){

            // No action needed if not expired

        } elseif($expired_exist == ''){

            update_post_meta($post_id, 're_post_expired', 0);

            wp_set_object_terms($post_id, NULL, 'offerexpiration', false );

        }

    }

}

Additional Info

Link on page with issue: https://couponzania.com/