Skip to content

Instantly share code, notes, and snippets.

@devinsays
Created November 5, 2020 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinsays/aa1fdcc2c018fed982702ce9d4d716fe to your computer and use it in GitHub Desktop.
Save devinsays/aa1fdcc2c018fed982702ce9d4d716fe to your computer and use it in GitHub Desktop.
active-subscriber-ids.sql
/*
* MySQL query to run site running WooCommerce Subscriptions.
* Selects all user ids for customers with an active subscriptions.
*/
select
meta.meta_value as user_id
from
wp_qftw_posts posts
left join wp_qftw_postmeta meta ON meta.post_ID = posts.ID
where
posts.post_type = 'shop_subscription'
and posts.post_status = 'wc-active'
and meta.meta_key = '_customer_user';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment