I have WooCommerce with Woo Subscriptions. When users go to the My Account → My Subscriptions page they normally see a full list of all of their subscriptions, active or not.
I would like to change that page to only show subscriptions they have which are a status of ‘active’ or ‘pending-cancel’.
My approach is to modify the query before it is run to put a conditional where status == ‘active’ || ‘pending-cancel’.
I’m stuck. I’ve tried different suggested methods of doing this including hooking into ‘pre_get_posts’, ‘posts_where’, ‘query_vars’
Here’s one example of what I’ve tried, and failed, to get working.
add_action('pre_get_posts', 'action_pre_get_posts');
function action_pre_get_posts($query) {
if ( is_account_page() && isset( $_GET['view-subscription'] ) && $query->is_main_query() ) {
$query->set( 'post_type', 'shop_subscription' );
$query->set( 'post_status', array( 'wc-active', 'wc-pending-cancel' ) );
}
}
Any ideas of how to do this?