0

我有超过 30,000 名用户拥有过期的 WooCommerce 订阅,我希望轻松扩展这些订阅。有没有办法可以以编程方式做到这一点?还是我可以运行的简单 MySQL 语句?有没有人这样做过?任何帮助将不胜感激!

4

1 回答 1

0
add_action( 'admin_init', 'change_expired_subscription_to_active' );

function change_expired_subscription_to_active() {
    $expired_subscriptions = get_posts( array( 'post_type' => 'shop_subscription', 'post_status' => 'wc-expired' ) );
    if(!empty(expired_subscriptions)){
      foreach ( $expired_subscriptions as $post ) {
        update_post_meta( $post->ID, '_requires_manual_renewal', true );
        wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'wc-active' ) );
    }
  }
}

试试这个代码

于 2020-04-28T16:36:52.417 回答