Update custom user meta after recurring payment in wordpress


I have a custom user meta as “Video Expiry”, after every successful checkout that field gets updated with current date+24 hrs. And after every 24 hrs the woocommerce subscription product gets renewed using recurring payment with the help of cron job. But the expiry field does not update on auto-renewal as the control does not reaches to function.php where the method is written to update the expiry field. Below is the function which updates expiry field after checkout. Is there any way to update the expiry after execution of cron job ? Thanks

add_action( 'woocommerce_thankyou', 'boo_checkout_save_meta');  //updating expiry date on order success
    function boo_checkout_save_meta( $order_id ) {
           $order = wc_get_order( $order_id );
           $user_id = $order->get_user_id();
           $new_time = date("Y-m-d H:i:s", strtotime('+24 hours'));
           update_user_meta( $user_id, 'video_expiry', $new_time);
Shujaat Shaikh 4 months 0 Answers 10 views 0

Leave an answer